Community Sites
Create your own community website and start earning today !
It's Free !
 
Communities Members BookmarksPolls Fresher Jobs Strange Photos Academic Projects New Member FAQ  



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

website counter




C program of matrix addition,substraction,and multiplication


Posted Date: 15 Mar 2008    Resource Type: Articles/Knowledge Sharing    Category: Computer & Technology

Posted By: ashish singh       Member Level: Diamond
Rating:     Points: 5




/* Program of addition,substraction,and multiplication of matrix */

#include
#include
void read_mat(int m,int n,int a[5][5])
{
int i,j;
for(i=0;i {
for(j=0;j {
printf("\n Enter element :");
scanf("%d",&a[i][j]);
}
}
void print_mat(int m,int n,int a[5][5])
{
int i,j;
for(i=0;i {
for(j=0;jprintf(" %d",a[i][j]);
printf("\n");
}
}
void add_mat(int m,int n,int a[5][5],int b[5][5],int s[5][5])
{
int i,j;
for(i=0;i {
for(j=0;j {
s[i][j]=a[i][j]+b[i][j];
}
}
}
void sub_mat(int m,int n,int a[5][5],int b[5][5],int sd[5][5])
{
int i,j;
for(i=0;i {
for(j=0;j {
sd[i][j]=a[i][j]-b[i][j];
}
}
}
void mul_mat(int m,int n,int q,int a[5][5],int b[5][5],int mt[5][5])
{
int i,j,k;
for(i=0;i {
for(j=0;j {
mt[i][j]=0;
for(k=0;k {
mt[i][j]=mt[i][j]+a[i][k]*b[k][j];
}
}
}
}
void main()
{
int m,n,p,q,i,j,a[5][5],b[5][5],s[5][5],sd[5][5],mt[5][5];
printf("\n Enter order of first matrix :");
scanf("%d%d",&m,&n);
printf("\n Order of second matrix :");
scanf("%d%d",&p,&q);
if((m!=p)&&(n!=q))
printf("\n Matrices are imcompatable for addotion and substraction");
else
{
printf("\n Read the element of first matrix ");
read_mat(m,n,a);
printf("\n Read the element of second matrix ");
read_mat(p,q,b);
printf("\n FIRST MATRIX IS ......\n");
print_mat(m,n,a);
printf("\n SECOND MATRIX IS ....\n");
print_mat(p,q,b);
add_mat(m,n,a,b,s);
printf("\n AFTER ADDITION MATRIX IS ....\n");
print_mat(m,n,s);
sub_mat(m,n,a,b,sd);
printf("\n AFTER SUBSTRACTION MATRIX IS ....\n");
print_mat(m,n,sd);
}
if(p==q)
{
mul_mat(m,n,q,a,b,mt);
printf("\n AFTER MULTIPLICATION MATRIX IS ....\n");
print_mat(m,q,mt);
}
else
printf("\n Matrices are incompatible for multiplication ");
getch();
}





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: C program to print all prime number between a range
Previous Resource: C Program to print reverse string by using stack
Return to Discussion Resource Index
Post New Resource
Category: Computer & Technology


Post resources and earn money!
 
Related Resources



Watch TV Channels
  • Watch Asianet TV online
  • Kairali TV in Internet
  • Surya TV online
  • Amritha TV Channel

  • Contact Us    Privacy Policy    Terms Of Use   

    SpiderWorks Technologies Pvt Ltd. 2006 - 2007 All Rights Reserved.