Skip to content

Instantly share code, notes, and snippets.

@sagardere
Created June 5, 2018 07:07
Show Gist options
  • Save sagardere/963f7fc46a56d55423e9ee504133e681 to your computer and use it in GitHub Desktop.
Save sagardere/963f7fc46a56d55423e9ee504133e681 to your computer and use it in GitHub Desktop.
#include<stdio.h>
void main()
{
int rows,starNo,spaceNo;
printf("Enter Rows:\n");
scanf("%d",&rows);
for(int i=1;i<=rows;i++)
{
starNo=i*2-1;
spaceNo=i+rows-starNo;
for(int j=0;j<spaceNo;j++)
{
printf("%c",' ');
}
for(int k=0;k<starNo;k++)
{
printf("%c",'*');
}
printf("\n");
}
for(int l=0;l<3;l++)
{
for(int m=0;m<(rows*2+1)/2;m++)
{
printf("%c",' ');
}
printf("%c\n",'*');
}
}
/*
I/P : Enter Rows: 7
O/P :
*
***
*****
*******
*********
***********
*************
*
*
*
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment