 You use a for loop when you have a specific number of iterations that you want to do. Sometimes, though, you don't know in advance how many iterations you'll need. For example, here, if you want to find the value of n for which the sum of squares up to and including n is greater than or equal to 100. To do a task like this, you need a while loop. Here's the flow chart of a generic while loop. It starts by testing a condition. If the condition is true, do the body of the loop and then return to test the condition. As long as the condition is true, do the loop body and return to test the condition again. When the condition is false, the loop is concluded. Here's how you write this generic while loop in C. As with the for loop, the style guidelines for this course are to always put braces around the loop body, even when it contains only one statement. Let's re-examine the example of finding the value of n for which the sum of squares up to and including n is greater than or equal to 100. Here's our flow chart. Start by setting n and the sum of squares to zero. If the sum of squares is less than 100, add one to n, add n squared to the sum, and to see how things are progressing, print them. Then loop back to the condition. Eventually, the sum of squares will not be less than 100. We will have achieved our goal and can print the answer. Here's the C program. It initializes the variables, and here is the while loop with its condition. The parentheses are required and, by convention, always put a space between the while and the opening parenthesis. Here, in the braces, is the body of the loop. It adds one to n using the post increment plus plus operator, adds n squared to the sum of squares, and prints their current values. Eventually, sum squared will not be less than 100. The loop will conclude and will print our results. Let's compile this and run it, and there's the answer. And that is a basic while loop in C.