
Call 1800-123-2003
"Smartindia is the best online tool for school students." Ms Deepa Chandran, Principal Anchal
"Smartindia is one of the best supplementary education tool for school students." Ms Pooja, Principal
WRITE A PROGRAM TO GENERATE THE FOLLOWING PATTERN. using 1 turbo 121 c++ 12321 1234321 123454321 |
#include<stdio.h> #include<conio.h> int main() { int num,r,c,sp,x; printf("Enter loop repeat number(rows):"); scanf("%d",&num); for(r=1; num>=r; r++) { for(sp=num-r; sp>=1; sp--) printf(" "); for(c=1; c<=r; c++) printf("%d",c); for(x=r-1; x>=1; x--) printf("%d",x); printf("\n"); } getch(); return 0; } |