dynamically create matrix c
int **A = (int **)malloc(N * sizeof(int*));
for(i=0; i<N; i++){
A[i] = (int *)malloc(N * sizeof(int));
}
dynamically create matrix c
int **A = (int **)malloc(N * sizeof(int*));
for(i=0; i<N; i++){
A[i] = (int *)malloc(N * sizeof(int));
}
transpose of a matrix in c
#include <stdio.h>
void main()
{
int a[10][10], transpose[10][10], m, n;
printf("Enter rows and columns: ");
scanf("%d %d", &m, &n);
printf("nEnter matrix elements:nn");
for (int i = 0; i < m; ++i)
{
for (int j = 0; j < n; ++j)
{
printf("Enter element a[%d%d]: ",i, j);
scanf("%d", &a[i][j]);
}
}
printf("nEntered matrix: n");
for (int i = 0; i < m; ++i)
{
for (int j = 0; j < n; ++j)
{
printf("%d ", a[i][j]);
if (j == n - 1)
printf("n");
}
}
for (int i = 0; i < m; ++i)
{
for (int j = 0; j < n; ++j)
{
transpose[j][i] = a[i][j];
}
}
printf("nTranspose of the matrix:n");
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < m; ++j)
{
printf("%d ", transpose[i][j]);
if (j == m - 1)
printf("n");
}
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us