C Language Nested Loops Set 3

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;
 }

C Language Programming Tutorial

C Language Tutorial Home    Introduction to C Language     Tokens     If Condition     goto statement and Labelname     Switch Statements     For loop     While Loop    Do while loop     break and continue    Functions    Recursion    Inbuild Functions    Storage Classes    Preprocessor    Arrays    Pointers     Structures and Unions    File Handling     Projects

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