how to made pyramid

Program:

#include<stdio.h>
#include<conio.h>
void main(void)
{
int row,c,n,temp;
printf("\nEnter a no of rows of pyramid of star:");
scanf("%d",&n);
temp=n;
for(row=1;row<=n;row++)
{
for(c=1;c<=temp;c++)
printf(" ");
temp--;
for(c=1;c<=2*row-1;c++)
printf("*");
printf("\n");
}

Output

 Enter a no of rows of pyramid of star:7
            *
          ***
        *****
      *******
    *********
  ***********
*************

  Note

printf(" ");

between the inverted comma space is not optional

Comments

Popular posts from this blog

Stack

EXTRA INFORMATION ABOUT TECHNOLOGY