While loop in C
While loop is used in programs for the repeated execution in a loop until a certain condition is satisfied the loop.
Syntax:
while(test-condition)
{
//body of the loop
}
Test-condition is indicated at the top and it takes the value of the expression before processing the body of the loop.The loop statements will be executed till the condition is true.When the condition becomes false the execution will be out of the loop.
lets take an example:
A program to print a string nine times on the output screen using while loop.
A program to add 10 consecutive numbers starting from 1.
A program to print factorial of a given number using while loop.
While loop Programs in C
Lets take some more examples of while loop in c
No comments:
Post a Comment