Star Pyramid Triangle Pattern Program in C
#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,k;
int p_height=5;
for(i=1;i<=p_height;i++)
{
for(k=p_height-1;k>=i;k--)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("* "); //space after '*'
}
printf("\n");
}
return 0;
}
"Another logic"
#include<stdio.h>
#include<conio.h>
void main()
{
int n=5; //size
int i,j;
clrscr();
for(i=1;i<=n;i++)
{
for(j=n;j>=1;j--)
{
if(i>=j)
printf("* "); //space after'*'
elseprintf(" ");
}
printf("\n");
}
getch();
}
No comments:
Post a Comment