while loop in C
The while loop in C language is used to iterate the part of program or statements many times.
In while loop, condition is given before the statement. So it is different from the do while loop. It can execute the statements 0 or more times.
When use while loop in C
The C language while loop should be used if number of iteration is uncertain or unknown.
Syntax of while loop in C language
The syntax of while loop in c language is given below:
Flowchart of while loop in C
Example of while loop in C language
Let's see the simple program of while loop that prints table of 1.
Output
1243 586 7 910
Program to print table for the given number using while loop in C
Output
Enter a number: 5050 100 150 200 250500300 350 400450
Enter a number: 100100 200 300 400 5001000600 700 800900
Infinitive while loop in C
If you pass 1 as a expression in while loop, it will run infinite number of times.
No comments:
Post a Comment