Pyramid Problem No. 72
Q.72 Write a C program to print the following number pyramid using function:
1 2 3 4 5 6 7 8 9 1 2 3 4 5 6
Solving in C:#include <stdio.h>
pattern_print();
int main(){
pattern_print();
return 0;
}
pattern_print(){
int n=5,row,col,count=1;
for(row=1; row<=n; row++){
for(col=1; col<=row; col++) {
if(count>9) count=1;
printf("%d ",count++);
}
printf("\n");
}
}
Comments
Post a Comment