Sorry to delete the previous version of this program, but this one is much more concise and sophisticated. I have written this program for a 3*3 matrix, but if you want to change it, just enter additional variables to store the order of the matrix and then replace the "3"s of the program with them as needed. It's easy. So here we go:
#include
#include
void swap(int *x,int *y);
main()
{
int i,j,k,m,n;
int matrix[3][3];
printf("Enter the matrix: \n\n");
for (i=0;i<3;++i)
{
printf("\nEnter #%d row: ",(i+1));
for (j=0;j<3;++j)
scanf("%d",&matrix[i][j]);
}
printf("\n\n");
for (j=0;j<3;++j)
{
for (i=0;i<3;++i)
if (i>j)
swap(&matrix[i][j],&matrix[j][i]);
}
printf("The transposed matrix is: \n\n");
for (i=0;i<3;++i)
{
for (j=0;j<3;++j)
printf("%4d",matrix[i][j]);
printf("\n\n");
}
}
void swap(int *x,int *y)
{
int t=*x;
*x=*y;
*y=t;
return;
}
#include<iostream.h>
#include<conio.h>
class A
{
int a[2][2],b[2][2],
x[2][2],y[2][2],
first[2][2],second[2][2],
c,d,e;
public:
void read()
{
y[0][0]=0;
y[1][0]=0;
y[0][1]=0;
y[1][1]=0;
x[0][0]=0;
x[0][1]=0;
x[1][0]=0;
x[1][1]=0;
first[0][0]=0;
first[0][1]=0;
first[1][0]=0;
first[1][1]=0;
second[0][0]=0;
second[0][1]=0;
second[1][0]=0;
second[1][1]=0; cout<<"Enter the value for first matrix : "<<endl;
for(c=0;c<2;c++)
{
for(d=0;d<2;d++)
{
cin>>a[c][d];
}
} cout<<"Enter the value for second matrix : "<<endl;
for(c=0;c<2;c++)
for(d=0;d<2;d++)
cin>>b[c][d]; for(c=0;c<2;c++)
for(d=0;d<2;d++)
x[c][d]=a[c][d]+b[c][d]; for(c=0;c<2;c++)
for(d=0;d<2;d++)
for(e=0;e<2;e++)
y[c][e]+=a[c][d]*b[d][e]; for(c=0;c<2;c++)
for(d=0;d<2;d++)
first[c][d]=a[d][c];
first[c][d]=a[c][d]; for(c=0;c<2;c++)
for(d=0;d<2;d++)
second[c][d]=b[d][c];
second[c][d]=b[c][d];
}
void addition()
{
cout<<"Addition of matrix : "<<endl;
for(c=0;c<2;c++)
{
for(d=0;d<2;d++)
{
cout<<" "<<x[c][d];
}
cout<<endl;
}
} void multiplication()
{
cout<<"Multiplication of matrix : "<<endl;
for(c=0;c<2;c++)
{
for(d=0;d<2;d++)
{
cout<<" "<<y[c][d];
}
cout<<endl;
}
} void transpose()
{
cout<<"Transpose for first matrix : "<<endl;
for(c=0;c<2;c++)
{
for(d=0;d<2;d++)
{
cout<<" "<<first[c][d];
}
cout<<endl;
}
cout<<"Transpose for second matrix : "<<endl;
for(c=0;c<2;c++)
{
for(d=0;d<2;d++)
{
cout<<" "<<second[c][d];
}
cout<<endl;
}
}
}; void main()
{
clrscr();
A a;
a.read();
a.addition();
a.multiplication();
a.transpose();
getch();
}
#include <stdio.h> #include <conio.h> void transpose(int a[10][10],int ,int); /*Function prototype*/
void main() { int i,j,m,n; int a[10][10], b[10][10]; clrscr(); printf("Enter the order of matrix a\n"); scanf("%d %d", &m, &n); printf("Enter the elements of matrix\n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) { scanf("%d",&a[i][j]); } } printf("Matrix a is\n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) { printf("%3d",a[i][j]); } printf("\n"); } transpose(a,i,j)/*Function call*/ getch(); /* Finding Transpose of matrix*/ void transpose(int a[10][10],int m,int n)/*Function definition*/ for(i=0;i<m;i++) { for(j=0;j<n;j++) { b[i][j] = a[j][i]; } } printf("Its Transpose is\n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) { printf("%3d",b[i][j]); } printf("\n"); } } /*End of main()*/
#include<stdio.h>
#include<conio.h>
void main(){
int arr[3][3], arrT[3][3];
int i,j;
clrscr();
printf("Enter the 3x3 matrix:\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("Enter the element arr[%d][%d] : ",i,j);
scanf("%d",&arr[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
arrT[j][i] = arr[i][j];
}
}
printf("The transpose of the matrix is: \n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("\t%d",arrT[i][j]);
}
printf("\n");
}
getch();
}
//matrix and its transpose
#include<stdio.h>
#include<conio.h>
void main() {
clrscr();
int m, n, c, d, matrix[10][10],transpose[10][10];
printf("Enter the number of rows and columns of matrix ");
scanf("%d %d",&m, &n);
//storing the elements of matrix
printf("Enter the elements of matrix \n");
for( c = 0 ; c < n ; c++ ) {
for( d = 0 ; d < m ; d++ ) {
scanf("%d",&matrix[c][d]);
}
}
printf("The matrix you have entered is:\n");
for( c = 0 ; c < n ; c++ ) {
for( d = 0 ; d < m ; d++ ) { //m is number of rows
printf("%d\t",matrix[c][d]);
}
printf("\n");
}
//making transpose
for( c = 0 ; c < n ; c++ ) {
for( d = 0 ; d < m ; d++ ) {
transpose[d][c] = matrix[c][d];
}
}
printf("Transpose of entered matrix :-\n");
for( c = 0 ; c < m ; c++ ) {
for( d = 0 ; d < n ; d++ ) { /* after transpose number of rows is equal to no. of columns of original matrix */
printf("%d\t",transpose[c][d]);
}
printf("\n");
}
getch();
}
Output:
Enter the number of rows and columns of matrix 3 2
Enter the elements of matrix
1 2 3 4 5 6
The matrix you have entered is
1 2 3
4 5 6
Transpose of entered matrix:
1 4
2 5
3 6
#include<iostream.h>
int main()
{
int a[3][3];
int tr[3][3];
int i,j;
cout<<"Enter elements of matrix : ";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cin>>a[i][j];
}
}
cout<<"original matrix : ";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<a[i][j];
}
cout<<"\n";
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
tr[i][j]=a[j][i];
}
}
cout<<"\n\ntranspose of matrix : ";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<tr[i][j];
}
cout<<"\n";
}
return 0;
}
You basically write a nested for loop (one for within another one), to copy the elements of the matrix to a new matrix.
Write a program in c++ that take input in a integer matrix of size 4*4 and find out if the entered matrix is diagonal or not.
This is a directive, not a question.
A c program is also known as a computer program. A singular matrix has no inverse. An equation to determine this would be a/c=f. <<>> The determinant of a singular matix is zero.
By using those two functions in your code.
You basically write a nested for loop (one for within another one), to copy the elements of the matrix to a new matrix.
Sp[[Q/Write a 8085 microprocessor program to find A inverse and A transpose if A is a 3x3 matrix|Answer]]ell chec[[Q/Write a 8085 microprocessor program to find A inverse and A transpose if A is a 3x3 matrix&action=edit&section=new|Answer it!]]k your answe[[Q/Discuss:Write a 8085 microprocessor program to find A inverse and A transpose if A is a 3x3 matrix|Disc]][[help/answering questions|guidelin]]Spell check your answeresussionr[[help/signing in|full benefits]] Save C[[Q/Write a 8085 microprocessor program to find A inverse and A transpose if A is a 3x3 matrix|Write a 8085 microprocessor program to find A inverse and A transpose if A is a 3x3 ]][[Q/Write a 8085 microprocessor program to find A inverse and A transpose if A is a 3x3 matrix&action=edit&section=new|Answering 'Write a 8085 microprocessor program to find A inverse and A transpose if A is a 3x3 matrix?']]matrix?ancel[[Q/How many animals are in West Texas|How many animals are in West Texas?]][[Q/How do you increase the number of four wheelers vehicles for servicing in a Service workshop|How do you increase the number of four wheelers vehicles for servicing in a]][[Q/How do you increase the number of four wheelers vehicles for servicing in a Service workshop|How do you increase the number of four wheelers vehicles for servicing in a Service workshop?]] Service workshop?[[Q/How do you increase the number of four wheelers vehicles for servicing in a Service workshop|How do you increase the number of four wheelers vehicles for servicing in a Service workshop?]]More Q&A
i cant write
write a program to multily 3*3 matrix.
how to write a program for matrix multiplication in microprocesspr
Write a program in c++ that take input in a integer matrix of size 4*4 and find out if the entered matrix is diagonal or not.
A C program to square matrix is a math problem. In the math problem you write down all the outer boundary values of matrix in a circle, then write down the inner value.
Yes, do write. That's what you always have to do when you have got a homework-program.
bgfygfrhjyuyhh
This is a directive, not a question.
matrix
#include<