Get the following Output:
2 2 2 2 2
4 4 4 4 4
6 6 6 6 6
8 8 8 8 8
10 10 10 10 10
Source Code:
13. Using For Loop
#include <stdio.h> int main() { int i,j; for(i=2;i<=10;i=i+2) { for(j=1;j<=5;j++) { printf("%d ",i); } printf("\n"); } return 0; }
14. Using While Loop
/* using while loop */ #include <stdio.h> int main() { int i=1,j; while(i<=5) { j=1; while(j<=5) { printf("%d ",i*2); j++; } printf("\n"); i++; } return 0; }
Get the following Output:
1 1 1 1 1
3 3 3 3 3
5 5 5 5 5
7 7 7 7 7
9 9 9 9 9
Source Code:
15. Using For Loop
#include <stdio.h> int main() { int i,j; for(i=1;i<=9;i=i+2) { for(j=1;j<=5;j++) { printf("%d ",i); } printf("\n"); } return 0; }
16. Using While Loop
/* using while loop */ #include <stdio.h> int main() { int i=1,j; while(i<=5) { j=1; while(j<=5) { printf("%d ",i*2-1); j++; } printf("\n"); i++; } return 0; }
Get the following Output:
5 5 5 5 5
10 10 10 10 10
15 15 15 15 15
20 20 20 20 20
25 25 25 25 25
Source Code:
17. Using For Loop
#include <stdio.h> int main() { int i,j; for(i=5;i<=25;i=i+5) { for(j=1;j<=5;j++) { printf("%d ",i); } printf("\n"); } return 0; }
18. Using While Loop
/* using while loop */ #include <stdio.h> int main() { int i=1,j; while(i<=5) { j=1; while(j<=5) { printf("%d ",i*5); j++; } printf("\n"); i++; } return 0; }
Tutorials | Technical Questions | Interview Questions |
---|---|---|
C Programming C++ Programming Class 11 (Python) Class 12 (Python) |
C Language C++ Programming Python |
C Interview Questions C++ Interview Questions C Programs C++ Programs |