Problem: Write a c program to print Pyramid Patterns.
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
Source Code:
- /*
- * C Program to print full pyramid pattern using *
- */
- #include<stdio.h>
- #include<conio.h>
- int main()
- {
- int row, space, rows, star=0;
- printf("Enter the number of rows in pyramid\n");
- scanf("%d",&rows);
- for(row = 1;row <= rows; row++)
- {
- /* Printing spaces */
- for(space = 1; space <= rows-row; space++)
- {
- printf(" ");
- }
- /* Printing stars */
- while(star != (2*row - 1))
- {
- printf("* ");
- star++;;
- }
- star=0;
- printf("\n");
- }
- getch();
- return 0;
- }
Outputs:
0 comments:
Post a Comment