write a program to printing following pattern in c.



QUESTION:- write a program to printing following pattern in c. 

1  

2 2  

3 3 3  

4 4 4 4 

5 5 5 5 5 

 

#include <stdio.h>

#include <conio.h>

int main()

{

    int i, j, no;

    printf("enter a value: ");

    scanf("%d", &no);

    for (i = 1; i <= no; i++)

    {

        for (j = 1; j <= i; j++)

        {

            printf("%d ", i);
        }

        printf("\n");
    }

    return 0;

    getch();
}

 

OUTPUT

enter a value: 5

1 

2 2

3 3 3

4 4 4 4

5 5 5 5 5


Follow our page for regular updates.

0 Comments