Wednesday, 13 August 2014

#include<stdio.h>
#include<conio.h>
int main()
{
          int mat[10][10];
          int a,b,row,col;
          printf("Size of 2D array:\n");
          scanf(%d%d,&row,&col);
          printf("Enter %d elements\n",(row*col));
          for(a=0;a<row;a++);
          for(b=0;b<col;b++);
          scanf("%d,&mat[a][b]);
          printf("The matrix is \n");
          for(a=0;a<row;a++)
          {
                            for(b=0;b<col;b++)
                            }
                            printf("%d",mat[a][b];
                            }
                            printf("\n");
                            }
                            printf("\nTranspose Matxix\n");
                            for(a=0;a<col;a++)
                            {
                                              for(b=0;b<row;b++)
                                              {
                                                                printf("%d",mat[b][a];
                                                                }
                                                                printf("\n");
                                                                }
                                                                getch();
                                                                return0;
                                                                }
Output:
Size of 2D array
2
3
Enter 6 elements
4
5
8
9
7
2
The matrix is
4 5 8
9 7 2
The transpose of the matrix is
4 9
5 7
8 2

                                                              
                                                             
 

No comments:

Post a Comment

Note: only a member of this blog may post a comment.