Looping in C
6
LOOPS
-
Upload
prabhu-govind -
Category
Education
-
view
48 -
download
5
description
Looping in C in S-Teacher
Transcript of Looping in C
LOOPS
FOR LOOP
The syntax of for loop isfor(initialisation;condition checking;increment){
set of statements}
The Example for for loop:// Program to print Hello 10 timesfor(i=0;i<10;i++){
printf(“Hello”);}
WHILE LOOP The syntax for while loopwhile(condition){
statements;}
Example for while loop:a=10;while(a != 0){
printf(“%d/t”,a);a- -;
}Output: 10 9 8 7 6 5 4 3 2 1
DO WHILE LOOP The syntax of do while loopdo{
set of statements}while(condition)
Example of do-while loop:i=10;do{
printf(“%d/t”,i);i--;
}while(i!=0)
Output:10 9 8 7 6 5 4 3 2 1