Hello friends, today I want to write about Pyramid. How can you create a pyramid in C. It is very easy to make a pyramid in C. For create a pyramid in C, you must have the understanding of how for loop works.
when input is 4. If you want to create this type of pyramid you can follow the program.
#include<stdio.h>
#include<conio.h>
main()
{
clrscr();
int i,j,n,k;
printf("Enter a value : ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=n-i;j++)
printf(" ");
{
for(j=1;j<=i;j++)
printf("*");
j=1;
for(j=i;i>=j;j--)
if(j==0)
break;
else
{
k=j-1;
if(k==0)
break;
else
printf("*");
}
printf("\n");
}
}
getch();
}
post by Arnob
No comments:
Post a Comment