Pyramid Problem No. 80
Q.80 Even-odd number star pyramid as:
1 *2 1*3 *2*4 1*3*5
Solving in C:#include <stdio.h> int main(){ int row,col; for(row=1; row<=5; row++){ for(col=1;col<=row; col++){ if((row%2==0 && col%2==1) || (row%2==1 && col%2==0)) printf("*"); else printf("%d",col); } printf("\n"); } return 0; }
Comments
Post a Comment