QUESTION:- print a pattern as shown below
1
2 3
4 5 6
7 8 9 10
#include <stdio.h>
#include <conio.h>
int main()
{
    int i, j, k, no, n = 0;
    printf("Enetr a value: ");
    scanf("%d", &no);
    // rows
    for (i = 1; i <= no; i++)
    {
        // space
        for (j = no; j >= i; j--)
        {
            printf(" ");
        }
        // display
        for (k = 1; k <= i; k++)
        {
            n++;
            printf("%d ", n);
        }
        printf("\n");
    }
    return 0;
    getch();
}
OUTPUT
enter a value: 4
1
2 3
4 5 6
7 8 9 10
Note:- you can make changes to all the patterns according to your wants and need.
 

 
 
0 Comments