title: Converting "for" loop to "while" loop
body: <p>I´m currently working on my semester work and this is a piece of my code. As you can see there is a for loop with some if statements where I am working with a structure. I was thinking of converting this for loop onto a while loop but I´m not quite sure how. Maybe someone may give me a hint?  </p>
  
  <pre><code>for(X = 1; X &lt;= 100; X++) 
          {
            if(structure[X].number == -1)
            {
              structure[X].number = number;
              structure[X].first_info = position;
              structure[X].second_info = position;
              break;
            }
            if(structure[X].number == number)
            {
              if(structure[X].first_info == -1) 
                structure[X].first_info = position;
                structure[X].second_info = position;
                break;
            }
          }
  </code></pre>