title: How to determine how many times will a statement inside a loop will be executed with conditional statements
body: <p>There is a test that consists of 12 questions. each question must have a value greater than 4 points. all the question must add to 100. also all the questions must have an integer value. 
  so a possible combination may be 5,5,5,5,5,5,5,5,5,5,5,45</p>
  
  <p>there is a method that theoretically will give this result:</p>
  
  <pre><code>// this method will return the possible number of tests
  public static double PosibleNumberOfTests()
  {
      int q1, q2, q3, q4, q5, q6, q7, q8, q9, q10, q11, q12; // each question value
  
      double counter=0; // if there is a valid combination then counter will be increased by 1
  
      for (q12 = 5; q12 &lt; 46; q12++)
      {
          for (q11 = 5; q11 &lt; 46; q11++)
          {
              for (q10 = 5; q10 &lt; 46; q10++)
              {
                  for (q9 = 5; q9 &lt; 46; q9++)
                  {
                      for (q8 = 5; q8 &lt; 46; q8++)
                      {
                          for (q7 = 5; q7 &lt; 46; q7++)
                          {
                              for (q6 = 5; q6 &lt; 46; q6++)
                              {
                                  for (q5 = 5; q5 &lt; 46; q5++)
                                  {
                                      for (q4 = 5; q4 &lt; 46; q4++)
                                      {
                                          for (q3 = 5; q3 &lt; 46; q3++)
                                          {
                                              for (q2 = 5; q2 &lt; 46; q2++)
                                              {
                                                  for (q1 = 5; q1 &lt; 46; q1++)
                                                  {
                                                      if (q1 + q2 + q3 + q4 + q5 + q6 + q7 + q8 + q9 + q10 + q11 + q12 == 100)
                                                          counter++;  // here is what we need. How many times will this line be executed!
                                                  }
                                              }
                                          }
                                      }
                                  }
                              }
                          }
                      }
                  }
              }
          }
  
      }
      return counter;
  }
  </code></pre>
  
  <p>note that I created each loop for values less than 46 because if all questions must have a value greater than 4 it will be impossible for a question to be worth 50 points for example.</p>
  
  <h2>Edit</h2>
  
  <p>Sorry people I think I am not explaining my self clearly. I piked 12 questions as a random guess. This example may have been with a test with 100 questions. I need something like what dlev mentioned in his comment. I also know I can place breaks in the loops to make the method more efficient. if the sum is greater than 100 then why continue looping just brak out of the corresponding loop</p>