While Loop in C

Like do-while loop, While loop is the most commonly used looping construct to repeat a process or calculation for a set or collection of inputs or storage based on a condition. It is a looping technique when you want to execute the required process based on a condition for the entire input collection. Below is a simple C program using while looping.

Example 1: Rocket count down

main(){
             int a = 10;
   
            while( a >= 0 ){
                 printf("%d.\n",a);
            }

             printf("The rocket takes off..\n");
      }

Add a Comment

Your email address will not be published. Required fields are marked *