Pyramid
A pyramid is a structure whose outer surfaces are triangular and converge to a single step at the top, making the shape roughly a pyramid in the geometric sense.
QUESTION:- print a pattern as shown below
*
* *
* * *
* * * *
#include <stdio.h>
#include <conio.h>
int main()
{
int i, j, k, no;
printf("Enter a value: ");
scanf("%d", &no);
// rows
for (i = 1; i <= no; i++)
{
// space
for (j = no; j >= i; j--)
{
printf(" ");
}
// display
for (k = 1; k <= i; k++)
{
printf("* ");
}
printf("\n");
}
return 0;
getch();
}
Note:- you can make changes to all the patterns according to your wants and need.
OUTPUT
Enter a value: 5
*
* *
* * *
* * * *
* * * * *
0 Comments