Pyramid Problem No. 75
Q.75 Write a C program to print number character pyramid as:
1 a 21 ba 321 cba 4321 dcba 54321 edcba
Solving in C:#include <stdio.h>
int main(){
int n=5,row,col,count;
for(row=1; row<=n; row++){
for(col=1,count=row; col<=row; col++,count--) printf("%d",count);
for(col=1;col<=n-row;col++) printf(" ");
printf("\t");
for(col=1,count=96+row; col<=row; col++) printf("%c",count--);
printf("\n");
}
return 0;
}
Comments
Post a Comment