V-Shape Pyramid

Q. Write a C program to print the following V symbol star pyramid as:

*     *
 *   *
  * *


/*c pyramid program for v-symbol*/
int main()

 int num=4,r,c,sp;
 for(r=1,c=num+1; r<=num; r++,c=c-2)
   for(sp=r; sp>1; sp--)
      printf(" ");
   for(sp=c; sp>=1; sp--)
      printf(" ");
 return 0;

The output of above program would be:

Output of V-Shape C pyramid program
Figure : Screen shot for V-Shape pyramid C program

No comments:

Post a Comment