Table of Contents
while loop
/* Author : ITVoyagers (https://itvoyagers.in/) Date :25th December 2018 Description : While loop. */ #include<stdio.h> void main() { int r=0; while(r<5) { printf("%in",r); r++; } }
Output:
0
1
2
3
4
do-while loop
/* Author : ITVoyagers (https://itvoyagers.in/) Date :25th December 2018 Description : do-While loop. */ #include<stdio.h> void main() { int r=0; do { printf("%in",r); r++; } while(r>5); }
Output:
0
for loop
/* Author : ITVoyagers (https://itvoyagers.in/) Date :25th December 2018 Description : for loop. */ #include<stdio.h> void main() { int r; for(r=1;r<=5;r++) { printf("%dn",r); } }
Output:
1
2
3
4
5
Nested loop
/* Author : ITVoyagers (https://itvoyagers.in/) Date :25th December 2018 Description : Nested loop. */ #include<stdio.h> void main() { int r,c; for(r=1;r<=5;r++) { for(c=1;c<=r;c++) { printf("*"); } printf("n"); } }
Output:
*
**
***
****
*****