Star Pattern 11

Star Pyramid Pattern Program in C 

#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,k;
int p_height=5;
for(i=p_height;i>=1;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=n;i>=1;i--)
{
for(j=n;j>=1;j--)
{
if(i>=j)
printf("*  ");  //space after'*'
else
printf(" ");
}
printf("\n");
}
getch();
}

No comments:

Post a Comment