Posted on Leave a comment

How use While loop example in ‘C’

How use While loop example in ‘C’

  1. #include <stdio.h>
  2. int main()
  3. {
  4.   int c = 1;  // Initializing variable
  5.   while (c <= 10)  // While loop will execute till the condition is true
  6.   {
  7.     printf(“%d “, c);  // Note the space after %d for gap in the numbers we want in output
  8.     c++;
  9.   }
  10.   return 0;
  11. }

Output:

***********************************
1 2 3 4 5 6 7 8 9 10

***********************************

Leave a Reply

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