Pyramid Problem No. 76

 Q.76 Write a C program to print 0 and 1 number triangle as:

1
01
010
1010
10101

Solving in C:

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


Comments

Popular posts from this blog

Pyramid Problem No. 90

Pyramid Problem No. 74

Pyramid Problem No. 85