Q. Write a C program to make a continuous number pyramid with adding digit "Zero" as:
1
02
003
0004
00005
000006
0000007
00000008
000000009
Ans.
/*c program for making a continuous number pyramid*/
#include<stdio.h>
int main()
{
int r,c;
printf("1\n");
for(r=2; r<=9; r++)
{
for(c=1; c<=r; c++)
{
if(c==r)
printf("%d",r);
else
printf("0");
}
printf("\n");
}
getch();
return 0;
}
You might also like:
1
02
003
0004
00005
000006
0000007
00000008
000000009
Ans.
/*c program for making a continuous number pyramid*/
#include<stdio.h>
int main()
{
int r,c;
printf("1\n");
for(r=2; r<=9; r++)
{
for(c=1; c<=r; c++)
{
if(c==r)
printf("%d",r);
else
printf("0");
}
printf("\n");
}
getch();
return 0;
}
/***********************************************************
The output of above program would be:
***********************************************************/
Figure: Screenshot for How to make continuous number pyramid with Zero C Program |
You might also like:
No comments:
Post a Comment