do while loop in C
To execute a part of program or code several times, we can use do-while loop of C language. The code given between the do and while block will be executed until condition is true.
In do while loop, statement is given before the condition, so statement or code will be executed at lease one time. In other words, we can say it is executed 1 or more times.
It is better if you have to execute the code at least once.
do while loop syntax
The syntax of C language do-while loop is given below:
Flowchart of do while loop
do while example
There is given the simple program of c language do while loop where we are printing the table of 1.
Output
1243 586 7 910
Program to print table for the given number using do while loop
Output
Enter a number: 55 10 15 20 25 305035 4045
Enter a number: 1010 20 30 40 50 6010070 8090
Infinitive do while loop
If you pass 1 as a expression in do while loop, it will run infinite number of times.
No comments:
Post a Comment