Pages

Thursday, 2 February 2017

Half Pyramid C Language

Half Pyramid C Language Code
/*   ################################
     Girfa Student Help
     Half 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;
     while(i<5)
     {
           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--;

     }
}


No comments:

Post a Comment