1#include<stdio.h>
2int main()
3{
4int i,j,n;
5printf("ENTER THE NUMBER OF ROWS YOU WANT TO PRINT * PYRAMID PATTERN\n");
6scanf("%d", &n);
7for(i = 1 ; i <= n ; i++)
8{
9 for (j = 1 ; j <= 2*n-1 ; j++)
10{
11 if (j >= n-(i-1) && j <= n+(i-1))
12 { printf("*"); }
13 else
14 {printf(" "); }
15}
16printf("\n");
17}
1#include <stdio.h>
2
3int main(){
4 int i,j,n,;//declaring variables
5
6 /*
7 At first half pyramid
8 *
9 **
10 ***
11 ****
12 *****
13 ******
14 *******
15 ********
16 */
17 printf("Enter rows: \n");
18 scanf("%d",&n);
19
20 printf("half pyramid\n\n");
21 for(i=0;i<n;i++){ //loop for making rows
22 for(j=0;j<i;j++){ //loop for making stars. Here "i" is row number and n is total row number. so for making 1 star after 1 star you've to put variable "i"
23 printf("* ");
24 }
25 //printing new line
26 printf("\n");
27 }
28
29 printf("\n\n");
30
31
32
33
34
35 /*
36 making full pyramids
37
38 *
39 ***
40 *****
41 *******
42 *********
43 ***********
44
45 */
46 printf("full pyramid\n\n");
47 //the first loop is for printing rows
48 for(i=1;i<=n;i++){
49 //loop for calculating spaces
50 for(j=1;j<=(n-i);j++){ //to calculate spaces I use totalRows-rowNo formula
51 printf(" ");
52 }
53
54 //loop for calculating stars
55 for(j=1;j<=((2*i)-1);j++){ //using the formula "2n-1"
56 printf("*");
57 }
58 //printing a new line
59 printf("\n");
60 }
61
62
63
64
65
66 return 0;
67
68
69}
70