Pyramid Problem No. 77
Q.77 Write the 1 and 0 number pyramid program as:
1 01 101 0101 10101
Solving in C:#include <stdio.h> int main(){ int n=5,row,col; for(row=1; row<=n; row++){ for(col=1;col<=row; col++){ if((row%2==0 && col%2==1) || (row%2==1 && col%2==0)) printf("0"); else printf("1"); } printf("\n"); } return 0; }
Comments
Post a Comment