#include<stdio.h>
#include<conio.h>
void main()
{
int ch;
int a[10][10],b[10],c[10],d[10][10],i,j,k=0;
int t,count1,count2,m,n,p,temp=0;
clrscr();
printf("\n1:identity matrix:");
printf("\n2:symmetric matrix :");
printf("\nenter your choice :");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("enter rows and column :");
scanf("%d%d",&m,&n);
if(m==n)
{
printf("\nenter the element :\n");
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(i==j)
{
b[k]=a[i][j];
k++;
}
}
}
t=0;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if(i!=j)
{
c[t]=a[i][j];
t++;
}
}
}
count1=0;
for(i=0;i<k;i++)
{
if(b[i]==1)
{
count1++;
}
}
count2=0;
for(i=0;i<t;i++)
{
if(c[i]==0)
{
count2++;
}
}
if(count1==k&&count2==t)
printf("it is identity matrix");
else
printf("it is not a identity matrix ");
}
else
printf("\nnot possible:");
break;
case 2:printf("\nenter rows and coloumn:");
scanf("%d%d",&m,&n);
if(m==n)
{
printf("\nenter the element of matrix :\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
d[i][j]=a[i][j];
}
}
for(i=0;i<m;i++)
{
for(j=i+1;j<n;j++)
{
temp=a[i][j];
a[i][j]=a[j][i];
a[j][i]=temp;
}
}
printf("\nthe transpose of matrix is :\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%d\t",a[i][j]);
}
printf("\n");
}
printf("\norigional matrix is :\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%d\t",d[i][j]);
}
printf("\n");
}
for(i=0;i<m;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i][j]==d[i][j])
{
p=0;
break;
}
else
p++;
}
printf("\n");
}
if(p==0)
printf("the it symmetric matrix");
else
printf("it is not symmetric maxtrix");
}
else
printf("\nnot possible");
break;
}
getch();
}
/*
1:identity matrix:
2:symmetric matrix :
enter your choice :1
enter rows and column :3 3
enter the element :
1 0 0
0 1 0
0 0 1
it is identity matrix
1:identity matrix:
2:symmetric matrix :
enter your choice :1
enter rows and column :3 3
enter the element :
7 8 9
1 4 5
3 6 2
it is not a identity matrix
1:identity matrix:
2:symmetric matrix :
enter your choice :2
enter the rows and coloumn :3 3
enter the element of matrix :
2 1 2
1 2 1
2 1 2
the transpose of matrix is :
2 1 2
1 2 1
2 1 2
origional matrix is :
2 1 2
1 2 1
2 1 2
the it symmetric matrix:
1:identity matrix:
2:symmetric matrix :
enter your choice :2
enter rows and coloumn:3 3
enter the element of matrix :
1 1 1
1 1 1
1 1 1
the transpose of matrix is :
1 1 1
1 1 1
1 1 1
origional matrix is :
1 1 1
1 1 1
1 1 1
the it symmetric matrix
1:identity matrix:
2:symmetric matrix :
enter your choice :2
enter rows and coloumn:3 3
enter the element of matrix :
7 8 9
1 4 5
3 6 5
the transpose of matrix is :
7 1 3
8 4 6
9 5 5
origional matrix is :
7 8 9
1 4 5
3 6 5
it is not symmetric maxtrix
*/
No comments:
Post a Comment