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

Answer Posted / mohammedayub.y(c.i.e.t)

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

getch();
return 0;
}

Is This Answer Correct ?    72 Yes 28 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is extern variable in c with example?

540


If one class contains another class as a member, in what order are the two class constructors called a) Constructor for the member class is called first b) Constructor for the member class is called second c) Only one of the constructors is called d) all of the above

626


What are the main characteristics of c language describe the structure of ac program?

614


What is the difference between call by value and call by reference in c?

621


What is the use of f in c?

561






What are the usage of pointer in c?

705


What is the meaning of typedef struct in c?

598


What is the difference between fread and fwrite function?

642


Explain that why C is procedural?

662


What is string in c language?

630


Explain 'bit masking'?

657


How is a structure member accessed?

587


What is the difference between if else and switchstatement

1314


What is typedf?

674


Tell me with an example the self-referential structure?

568