1: #include<stdio.h>
2: #include<conio.h>
3: void displaymatrix(int nr,int nc,int x[10][10])
4: { 5: int i,j;
6: printf("The matrix is given below:\n\n"); 7: for(i=0;i<nr;i++)
8: { 9: for(j=0;j<nc;j++)
10: { 11: printf("%d ",x[i][j]); 12: }
13: printf("\n"); 14: }
15: }
16: void main()
17: { 18: int i,j,nr,nc,x[10][10];
19: printf("\nNo of rows:"); 20: scanf("%d",&nr); 21: printf("\nNo of columns:"); 22: scanf("%d",&nc); 23: for(i=0;i<nr;i++)
24: for(j=0;j<nc;j++)
25: x[i][j]=2*i+3*j;
26: displaymatrix(nr,nc,x);
27: getch();
28: }
No comments:
Post a Comment