Pyramid Problem No. 83
Q.83 Print any random number pyramid as:
4572 572 72 2
Solving in C:
#include <stdio.h>
int main(){
int n=4,row,col,count,skip_count;
for(row=n,skip_count=1; row>=1; row--,skip_count++){
for(col=1,count=n; col<=n; col++,count+=col-1){
if(skip_count>col) continue;
else{
if(col==n) printf("%d ",2);
else printf("%d ",count);
}
}
printf("\n");
}
return 0;
}
Comments
Post a Comment