ANSWERS: 2
  • helloo this program will work for any rows so for 10 rows u just enter 10 and u will get the answer k. #include<Stdio.h> #include<conio.h> void main() { int a[20][20],i,j,n,spc=25,k; printf("n enter the number of rows:"); scanf("%d",&n); for(i=0;i<n;i++) //outer loop for rows { for(k=spc-2*i;k>=0;k--) printf(" "); //to print the spaces for(j=0;j<=i;j++) //inner loop for columns { if(j==0||i==j) { a[i][j]=1; } else { a[i][j]=a[i-1][j-1]+a[i-1][j]; } printf("%4d",a[i][j]); } printf("n"); } getch(); }
  • try this one #include<Stdio.h> #include<conio.h> void main() { int a[20][20],i,j,n,m=25,k; printf("n enter the number of rows:"); scanf("%d",&n); for(i=0;i<n;i++) //outer loop for rows { for(k=m-2*i;k>=0;k--) printf(" "); //to print the spaces for(j=0;j<=i;j++) //inner loop for columns { if(j==0||i==j) { a[i][j]=1; } else { a[i][j]=a[i-1][j-1]+a[i-1][j]; } printf("%4d",a[i][j] ); } printf("n"); } getch(); }

Copyright 2023, Wired Ivy, LLC

Answerbag | Terms of Service | Privacy Policy