QUESTION:- Write a program in C to display the pattern like a pyramid using an asterisk and each row contain an odd number of asterisks.
*
***
*****
program
#include <stdio.h>
#include <conio.h>
int main()
{
int i, j, k, no;
printf("entre a value of no: ");
scanf("%d", &no);
// row
for (i = 1; i <= no; i++)
{
// space
for (j = no; j >= i; j--)
{
printf(" ");
}
// display
for (k = 1; k <= (i * 2) - 1; k++)
{
printf("*");
}
printf("\n");
}
return 0;
getch();
}
OUTPUT
entre a value of no: 5
*
***
*****
*******
*********
0 Comments