Site icon Matistics

C – Program to print a FULL-PYRAMID

For n = 5, the output will be:

#include<stdio.h>
int main(){
int n,step=1;
printf("Input the number of rows ");
scanf("%d",&n);
for(int i=1;i<=n;i++){
for(int j=n-1;j>=i;j--){
printf(" ");
}
for(int k=1;k<=step;k++){
printf("*");
}
step +=2;
for(int q=n-1;q>=i;q--){
printf(" ");
}
printf("\n");
}
return 0;
}

Exit mobile version