C Pyramid Number Pattern


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;
}

Comments

Popular posts from this blog

textcolor in c

wherex in c

traffic light program in c, traffic light simulation