Assignment No 08

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Object : Write a program in C to transpose of a 2- dimensional matrix.

Input :

#include<stdio.h>

#include<conio.h>

int main()

clrscr();

printf(“ Abu Shayan Salim \n”);

int i,j;

int a[3][3], transpose [3][3],r,c;

printf(“ enter rows and columns:”);

scanf(“%d%d,&r,&c);

printf(“\n enter matrix elements:\n”);

for(i=0; i<r; ++i)

for(j=0; j<c; ++j)

printf (“ enter element a%d%d:”,i,j);

scanf(“%d”,&a[i][j]);

for(i=0; i<r; ++i)

for(j=0; j<c; ++j)

{
printf (“%d”, a[i][j]);

if( j==c-1)

printf(“\n”);

for(i=0; i<r; ++i)

for(j=0; j<c; ++j)

transpose [j][i]= a[i][j];

printf (“\n transpose \n”);

for(“ i=0; i<r; ++i)

for(j=0; j<c; ++j)

printf (“%d”, transpose [i][j]);

if (j==r-1);

printf (“\n”);

}
getch();

return 0;

Output :

You might also like