please do this.. i have exam tomorrow
souvikdas5 (1)

#include<stdio.h>
#include<stdlib.h>
int trans(int ,int ,int ,int);
int main()
{
int
m1,m2,mul;
int m,n,i,j,flag=1;
printf("enter range for first matrix");
scanf("%d %d",&m,&n);
m1=(int*)malloc(msizeof(int));
for(i=0;i<m;i++)
{
(m1+i)=(int)malloc(nsizeof(int));
}
if(m!=n)
{
printf("not be orthogonal");
}
else
{
printf("enter element");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",((m1+i)+j));
}
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
(
((m2+j)+i))=(((m1+i)+j));
}
}
mul=trans(m1,m2,m,n);
}
printf("the elements are \n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(i==j&&(
((mul+i)+j))!=1)
flag=0;
if(i!=j&&(
(*(mul+i)+j))!=0)
flag=0;
}
}
if(flag==1)
{
printf("Given Matrix is Orthogonal Matrix\n");
}
else
{
printf("Given Matrix is not an Orthogonal Matrix\n");
}

}

int trans(int m1,int m2,int m,int n)
{
int
p= NULL;
int i,j,sum,k;
p=(int*)malloc(msizeof(int));
for(i=0;i<m;i++)
{
(p+i)=(int)malloc(nsizeof(int));
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{sum=0;
for(k=0;k<n;k++)
{
sum=sum+(((m1+i)+k))(((m2+k)+j));
}
(
(*(p+i)+j))=sum;
}
}
return p;
}

You are viewing a single comment. View All
theangryepicbanana (1136)

We cannot do your homework for you, but we can help you understand it better

souvikdas5 (1)

@theangryepicbanana thats ok.. i've solved it ... didn't initialize the m2 there

mwilki7 (520)

@souvikdas5 what kind of evil teacher is having you use double pointers

souvikdas5 (1)

@mwilki7 well fuck me..... but on a brighter side... i did the diagonal multiplication of two matrix today with double pointer... the logic was ok though.. didn't run ..had some scanf problem.. as its .exe stopped working.. so didn't get the output marks