write a program to print following pattern in c.


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

1  

2 3  

4 5 6  

7 8 9 10  


#include <stdio.h>

#include <conio.h>

int main()

{

    int i, j, no, k = 0;

    printf("enter a value: ");

    scanf("%d", &no);

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

    {

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

        {

            k++;

            printf("%d \t", k);
        }

        printf("\n");
    }

    return 0;

    getch();
}


OUTPUT

enter a value: 4

1  

2 3  

4 5 6  

7 8 9 10  


Follow our page for regular updates.

0 Comments