Thursday, 2 February 2017

Full Pyramid C Language

Full Pyramid Code

/*   ################################
     Girfa Student Help
     Full  Pyramid
     for more visit : http://girfahelp.blogspot.in/p/c-language.html
     ################################

*/
#include<stdio.h>
void main()
{
     int i,j,k=1,sp=10;
     i=1;
     /* Upper Part */
     while(i<5)
     {
           j=1;
           while(j<=sp)
           {
                printf(" ");
                j++;
           }
           j=1;
           while(j<=k)
           {
                printf("*");
                j++;
           }
           printf("\n");
           i++;
           sp--;
           k+=2;
     }
     /* Lower part */
     while(i>0)
     {
           j=1;
           while(j<=sp)
           {
                printf(" ");
                j++;
           }
           j=1;
           while(j<=k)
           {
                printf("*");
                j++;
           }
           printf("\n");
           i--;
           sp++;
           k-=2;
     }

     printf("\nFor Loop Implementation\n");
     for(i=1,sp=10,k=1;i<5;i++)
     {
           for(j=1;j<=sp;j++)
           {
                printf(" ");
           }
           for(j=1;j<=k;j++)
                printf("*");
           printf("\n");
           k+=2;
           sp--;

     }
     for(;i>0;i--)
     {
           for(j=1;j<=sp;j++)
                printf(" ");
           for(j=1;j<=k;j++)
                printf("*");
           printf("\n");
           k-=2;
           sp++;
     }
}