Q17 Write a program to produce the 10 digits pyramid output: 1 2 3 4 5 6 7 8 9 10

Write a program to produce the following output:ttt1ntt2t3nt4t5t6n7t8t9t10

Program: 110

Write a c program to produce the following pattern on computer screen:

            1 
        2       3
    4       5        6
7       8       9        10

#include<stdio.h>
#include<conio.h>
int main()
{
    int i, j, k, count=1;

    //for loop for all the rows=4

    for(i=1;i<=4;i++)
    {
        //add left space for pattern
        for(j=1;j<=4-i;j++)
        {
            printf("*");
        }

        //add element after space
        for(k=1;k<=i;k++)
        {
            printf(" %d",count);
            count++;
        }

    printf("\n");

    }
}

Output:

            1 
        2       3
    4       5        6
7       8       9        10

Lokesh Kumar: Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.
Related Post
Leave a Comment

This website uses cookies.