Glad to see you got it!
Now, indent it sensibly, change your variable names to more descriptive ones, and comment it so that you can understand it in three weeks time! :laugh:
void main()
{
clrscr();
int a[10][10],b[10][10];
int m, n, p, q, t, col;
int i, j;
printf("enter the no of row and columns :\n");
scanf("%d %d", &m, &n);
for (i = 1; i <= m; i++)
{
for (j = 1; j <= n; j++)
{
printf("a[%d][%d]= ", i, j);
scanf("%d", &a[i][j]);
}
}
printf("\n\n");
printf("\n\nThe matrix is :\n\n");
for (i = 1; i <= m; i++)
{
for (j = 1; j <= n; j++)
{
printf("%d", a[i][j]);
}
printf("\n");
}
t = 0;
printf("\n\nthe non zero value matrix are :\n\n");
for (i = 1; i <= m; i++)
{
for (j = 1; j <= n; j++)
{
if (a[i][j] != 0)
{
t = t + 1;
b[t][1] = i;
b[t][2] = j;
b[t][3] = a[i][j];
}
}
}
printf("\n");
printf("\n\t R C V \n");
printf(" \n \t%d %d %d \n", m, n, t);
for (i = 1; i <= t; i++)
{
printf(" \n \t%d %d %d \n", b[i][1], b[i][2], b[i][3]);
}
b[0][1] = n;
b[0][2] = m;
b[0][3] = t;
q = 1;
printf("\n\nthe transpose of the matrix :\n ");
if (t > 0)
{
for (i = 1; i <= n; i++)
{
for (j = 1; j <= t; j++)
{
if (b[j][2] == i)
{
a[q][1] = b[j][2];
a[q][2] = b[j][1];
a[q][3] = b[j][3];
q = q + 1;
}
}
}
}
printf("\n\n");
printf(" %d %d %d\n", b[0][1], b[0][2], b[0][3]);
for (i = 1; i <= t; i++)
{
printf("%d %d %d\n", a[i][1], a[i][2], a[i][3]);
}
getch();
}
That's the indent done for you!
[answered to remove from unanswered list]