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

Answer Posted / ashok kumar

void main()
{
int n,i,j,k=1;
clrscr();
printf("\n Enter a number : ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=i;j<n;j++)
printf(" ");
for(j=1;j<=i;j++)
printf(" %d ",k++);
printf("\n");
}
getch();
}

Is This Answer Correct ?    31 Yes 19 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define recursion in c.

688


What is a c token and types of c tokens?

575


write an algorithm to display a square matrix.

2207


Tell us bitwise shift operators?

586


What is the advantage of c?

600






What is spaghetti programming?

655


What is new line escape sequence?

790


What is the difference between struct and union in C?

546


How many loops are there in c?

569


Why we use break in c?

536


what are the advanced features of functions a) function declaration and prototypes b) calling functions by value or by reference c) recursion d) all the above

653


Why should I use standard library functions instead of writing my own?

658


Why calloc is better than malloc?

561


Explain how are 16- and 32-bit numbers stored?

771


Explain the binary height balanced tree?

708