Get the following Output:
5 10 15 20 25
5 10 15 20 25
5 10 15 20 25
5 10 15 20 25
5 10 15 20 25
Source Code
7. Using For Loop
#include <stdio.h> int main() { int i,j; for(i=1;i<=5;i++) { for(j=5;j<=25;j=j+5) { printf("%d ",j); } printf("\n"); } return 0; }
8. 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 ",j*5); j++; } printf("\n"); i++; } return 0; }
Get the following Output:
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
Source Code
9. Using For Loop
#include <stdio.h> int main() { int i,j; for(i=1;i<=5;i++) { for(j=1;j<=5;j=j+1) { printf("* "); } printf("\n"); } return 0; }
10. Using while Loop
/* using while loop */ #include <stdio.h> int main() { int i=1,j; while(i<=5) { j=1; while(j<=5) { printf("* "); j++; } printf("\n"); i++; } return 0; }
Get the following Output:
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5
Source Code
11. Using For Loop
#include <stdio.h> int main() { int i,j; for(i=1;i<=5;i++) { for(j=1;j<=5;j=j+1) { printf("%d ",i); } printf("\n"); } return 0; }
12. 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); j++; } printf("\n"); i++; } return 0; }