While Loop(Programme in C)
While Loop(Programme in C)
//title: While Loop
//brief:
prints value of i for each iteration starting from 1 to 9 using // while loop.
//result:
Value of i: 1
//
Value of i: 2
//
Value of i: 3
//
Value of i: 4
//
Value of i: 5
//
Value of i: 6
//
Value of i: 7
//
Value of i: 8
//
Value of i: 9
#include <stdio.h>
#include <stdlib.h>
//start of main function
int main()
{
//variable declaration
int i = 1;
//repeat loop 9 times.
while (i <= 9)
//execute below statement block till i<=9
{
printf("Value of i: %d\n", i);
//print value of i each time
i = i + 1; //increment indexing
variable i
}
//terminate main function and return 0 as output
return 0;
}
Comments
Post a Comment