New Member FAQ | Forums | Earn Revenue | Distance Education | Help Topics | Admissions 2013
Awards & Gifts
 
Login Login    Register      

ArticlesPractice TestsAsk ExpertsQuestion PapersJobsUniversitiesCollegesCoursesSchools

Active Members
TodayLast 7 Daysmore...

Join our online Google+ community for Bloggers, Content Writers and Webmasters




Resources » Articles/Knowledge Sharing » Computer & Technology

Write a Program To Add,Subtract,Multipications and Traspose of Two Matrices using functions?


Posted Date:     Category: Computer & Technology    
Author: Member Level: Silver    Points: 2


Write a Program To Add,Subtract,Multipications and Traspose of Two Matrices using functions?



 

Write a Program To Add,Subtract,Multipications and Traspose of Two Matrices using functions?

SOURCE CODE:


#include
#include
void add(int a[3][3],int b[3][3]);
void subt(int c[3][3],int d[3][3]);
void mult(int e[3][3],int f[3][3]);
void tranp(int g[3][3]);

void main()
{
int i,j,opt;
int x[3][3],y[3][3];
clrscr();
printf("This Program is Used to Perform ADDITION,SUBTRACTION,MULTIPICATION and TRANSPOSE on Two Matrices using functions\n");
printf("\n\tEnter The Value Of First Matrix:");
for(i=1;i<=3;i++)
{
for(j=1;j<=3;j++)
{
scanf("%d",&x[i][j]);
}
}

printf("\nEnter The Value Of Second Matrix:");
for(i=1;i<=3;i++)
{
for(j=1;j<=3;j++)
{
scanf("%d",&y[i][j]);
}
}



printf("\nSelect One Option given below:\n");
printf("\n\t1.ADDITION");
printf("\n\t2.SUBTRACTION");
printf("\n\t3.MULTIPICATION");
printf("\n\t4.TRANSPOSE");
printf("\n\tEnter Your value:");
scanf("%d",&opt);

switch(opt)
{
case 1:
add(x,y);
break;
case 2:
subt(x,y);
break;
case 3:
mult(x,y);
break;
case 4:
tranp(x);
break;
}
getch();
}
void add(int a[3][3],int b[3][3])
{
int z[3][3];
int i,j;
printf("\n");
for(i=1;i<=3;i++)
{

for(j=1;j<=3;j++)
{
z[i][j]=a[i][j]+b[i][j];
printf("\t %d",z[i][j]);
}
printf("\n");
}
}







void subt(int c[3][3],int d[3][3])
{
int z[3][3];
int i,j;
printf("\n");
for(i=1;i<=3;i++)
{

for(j=1;j<=3;j++)
{
z[i][j]=c[i][j]-d[i][j];
printf("\t %d",z[i][j]);
}
printf("\n");
}
}

void mult(int e[3][3],int f[3][3])
{
int z[3][3];
int i,j,k;
printf("\n");
for(i=1;i<=3;i++)
{

for(j=1;j<=3;j++)
{
z[i][j]=0;
for(k=1;k<=3;k++)
{

z[i][j]=e[i][k]*f[k][j]+z[i][j];
printf("\t %d",z[i][j]);
}
}
printf("\n");
}
}

void tranp(int g[3][3])
{
int z[3][3];
int i,j;




printf("\n");
for(i=1;i<=3;i++)
{
for(j=1;j<=3;j++)
{
z[i][j]=g[j][i];
printf("\t %d",z[i][j]);
}
printf("\n");
}
}




OUTPUT

This program is used to perform Addition,Subtraction,Multiplication and Transpose operations on Matrics by using Functions

Enter the value of first Matrix:1 5 7
4 6 9
4 7 9
Enter the value of Second Matrix:2 5 8
1 4 1
3 2 6

Select One option given Below:
1.Addition
2.Subtraction
3.Multiplication
4.Transpose

Enter your choice:1
5 10 15
6 10 2
7 9 15





Did you like this resource? Share it with your friends and show your love!





Responses to "Write a Program To Add,Subtract,Multipications and Traspose of Two Matrices using functions?"
Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: Requirements for a good Web Design
    Previous Resource: Write a Program to Search An Element in 1-Dimensional Array Using Linear Search.
    Return to Resources
    Post New Resource
    Category: Computer & Technology


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    Add  .  Subtract  .  Multipications  .  And  .  Traspose of Two Matrices  .  Data structure  .  

    Subscribe to Email
  • Get Jobs by Email
  • Forum posts by Email
  • Articles by Email
  • Online MembersAasrith Reddy
    Naresh Kumar Behera
    yash
    Venkiteswaran.
    akhil
    stylus
    Mahesh Gaikwad
    Divya
    DELPHIN VASANTHI R
    GAYATHRI DEVI
    Komal Sood
    More...


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    AdSense Revenue Sharing sites   Advertise   Talk to Tony John
    ISC Technologies, Kochi - India. Copyright © All Rights Reserved.