Pyramid Problem No. 57

 Q. 57 Write a C program to display odd number series pyramid as:

1
3  5  7
9 11 13 15 17 19

Solving in C:

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

Comments

Popular posts from this blog

Pyramid Problem No. 90

Pyramid Problem No. 74

Pyramid Problem No. 85