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

Answer Posted / ayas kumar das

#include"stdio.h"
int main()
{
int i,j,n;
printf("enter the number :");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
if(i>1)
{
for(j=i;j>1;)
{
printf("%d",j-1);
j=j-1;
}
}
printf("\n");
}
return 0;
}

Is This Answer Correct ?    12 Yes 20 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is array within structure?

578


Was 2000 a leap year?

624


Here is a neat trick for checking whether two strings are equal

560


Can we replace the struct function in tree syntax with a union?

774


What are enumerated types?

649






void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }

1251


What is %s and %d in c?

586


How does free() know explain how much memory to release?

615


Tell me the use of bit field in c language?

625


The file stdio.h, what does it contain?

663


What is external variable in c?

607


Why are all header files not declared in every c program?

596


What are the applications of c language?

621


What is use of bit field?

766


What is the difference between far and near in c?

599