Pyramid Problem No. 12

 Q.12 Write a program to generate a following numbers structure:

				1
			1	2
		1	2	3
	1	2	3	4
1	2	3	4	5


Solving in C:

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

Comments

Popular posts from this blog

Pyramid Problem No. 90

Pyramid Problem No. 74

Pyramid Problem No. 85