Pyramid Problem No. 52

 Q. 52 Write a C program to print the following star structure/fashion:

*********
 *******
  *****
   ***
    *
   ***
  *****
 *******
*********

Solving in C:

#include <stdio.h>
    int main(){
        int row,col; 
        for(row=5; row>=1; row--){
            for(col=1; col<=5-row; col++) printf(" ");
            for(col=1; col<=2*row-1; col++) printf("*");
            printf("\n");
        }
        for(row=1; row<=5; row++){
            for(col=1; col<=5-row; col++) printf(" ");
            for(col=1; col<=2*row-1; col++) printf("*");
            printf("\n");
        }
        return 0;
    }

Comments

Popular posts from this blog

Pyramid Problem No. 90

Pyramid Problem No. 74

Pyramid Problem No. 85