Answer to Question #13315 in C++ for swapnil sahu

Question #13315
display the following
1
121
12321
1234321
12321
121
1
1
Expert's answer
2012-08-21T10:11:23-0400
#include<stdio.h>
#include<conio.h>
int main()
{
int num,r,c,sp;
printf("Enter number of rows : ");
scanf("%d",&num);
for(r=1; r<=num; r++)
{
for(sp=num-r; sp>=1; sp--)
printf(" ");
for(c=1; c<=r; c++)
printf("%d",c);
for(c=r-1; c>=1; c--)
printf("%d",c);
printf("
");
}
for(r=1; r<=num; r++)
{
for(sp=r; sp>=1; sp--)
printf(" ");
for(c=1; c<=(num-r); c++)
printf("%d",c);
for(c=num-r-1; c>=1; c--)
printf("%d",c);
printf("
");
}
getch();
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS