Loop or repetition is also widely used in programming. We also need to know how to control the loop of program. Whether we want to control the loop by using sentinel value
(the value can be anything).
Loop can be divided by three types:-
1)while
2)do...while
3)for
While loop is basically we execute the condition first. If the condition is false, the program will exit. do...while loop is a loop where we execute the statement first and then the condition. This kind of loop quite similar to while loop, but the sequences between of both loops is difference. For loop is a bit special because the code and format of the loop is the simplest, shortest and at the same time the aim of loop is same as while and do...while loop.
while(condition){
statement; }
do{
statement;}
while(condition);
for(a=0;a<5;a++){
statement; }
Extra notes regarding loop, click the link below:-
https://docs.google.com/open?id=0BxksBzCNS-ZtNDA0MzJmZGYtMGJlYi00MmRlLTg4YjctYjg1YzZkNjEzYzM2
1)while
2)do...while
3)for
While loop is basically we execute the condition first. If the condition is false, the program will exit. do...while loop is a loop where we execute the statement first and then the condition. This kind of loop quite similar to while loop, but the sequences between of both loops is difference. For loop is a bit special because the code and format of the loop is the simplest, shortest and at the same time the aim of loop is same as while and do...while loop.
while(condition){
statement; }
do{
statement;}
while(condition);
for(a=0;a<5;a++){
statement; }
Extra notes regarding loop, click the link below:-
https://docs.google.com/open?id=0BxksBzCNS-ZtNDA0MzJmZGYtMGJlYi00MmRlLTg4YjctYjg1YzZkNjEzYzM2
No comments:
Post a Comment