Write a program in c to print
1
121
12321
1234321
123454321

Answer Posted / sabby

#include<stdio.h>
main()
{
int i,j,s,n;
printf("Enter the number of rows:");
scanf("%d\n",&n);
for(i=1;i<=n;i++)
{
for(s=1;s<=n-i;s++)
printf(" ");
for(j=1;j<=i;j++)
printf("%d",j);
j=j-2;
for(;j>=1;j--)
{
printf("%d",j);
}
printf("\n");
}
}

Is This Answer Correct ?    16 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is struct node in c?

623


What is spark map function?

582


Why clrscr is used after variable declaration?

1042


Can you apply link and association interchangeably?

680


How do we make a global variable accessible across files? Explain the extern keyword?

1423






What does the c in ctime mean?

571


What is the difference between text and binary i/o?

593


List the difference between a While & Do While loops?

640


What is keyword in c?

605


What is the use of header files?

607


if the area was hit by a virus and so the decrease in the population because of death was x/3 and the migration from other places increased a population by 2x then annually it had so many ppl. find our the population in the starting.

4507


Can a pointer point to null?

590


Write a program to implement a round robin scheduler and calculate the average waiting time.Arrival time, burst time, time quantum, and no. of processes should be the inputs.

627


What is %s and %d in c?

594


Is c++ based on c?

656