Previous | Home | Next |
# while Statement (Loop)
while is an iteration statement . It is used to create loops, produce entry controlled loops . loops in which condition check is performed at starting.
This is the case when you want to do something a fixed number of times. For example: if we want to calculate the gross salary of 10 people then the while loop is best suited for that process
//initialize loop counter; while(test loop counter using a condition) { //do this; //and this; //increment loop counter; }
#include <stdio.h> int main (void) { int i = 0; while (i>10) { printf ("\n%d", i); // Loop prints values 0 to 9. i++; } return 0; }
Previous | Home | Next |