Q. Write a C program to print the following C Pyramid Number Pattern program as:
11
11 10 11
11 10 9 10 11
11 10 9 8 9 10 11
Ans.
/* c pyramid number pattern program source code*/
#include<stdio.h>
int main()
{
int r,c,num=4,p,q=12,z;
for(r=1; r<=num; r++,q--)
{
for(c=1,p=11; c<=r; c++,p--)
printf(" %d",p);
for(c=1,z=q; c<r; c++,z++)
printf(" %d",z);
printf("\n");
}
getch();
return 0;
}
You might also like to read:
11
11 10 11
11 10 9 10 11
11 10 9 8 9 10 11
Ans.
/* c pyramid number pattern program source code*/
#include<stdio.h>
int main()
{
int r,c,num=4,p,q=12,z;
for(r=1; r<=num; r++,q--)
{
for(c=1,p=11; c<=r; c++,p--)
printf(" %d",p);
for(c=1,z=q; c<r; c++,z++)
printf(" %d",z);
printf("\n");
}
getch();
return 0;
}
/****************************************
The output of above C pyramid number pattern program as:
*****************************************/
Figure: Screen shot for C pyramid number pattern program |
You might also like to read:
0 komentar:
Post a Comment