Monday, February 17, 2020

while loop example


#include <stdio.h>

int main()
{
  int c = 1;  // Initializing variable

  while (<= 10)  // While loop will execute till the condition is true
  {
    printf("%d ", c);  // Note the space after %d for gap in the numbers we want in output
    c++;
  }

  return 0;
}


Output:

1 2 3 4 5 6 7 8 9 10

No comments:

Post a Comment