Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

XoOo13

  • one year ago

How to make a c program that computes for matrix operations (addition,subtraction,multiplication) (max of 3x3, can be 2x1, 1x3, etc.) using arrays and for loops? Please help me! :( i'm using dev-c++ compiler

  • This Question is Closed
  1. P.Rohith
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    its very easy for addition and subtraction: for example for addition: #include<stdio.h> #include<conio.h> void main() { int a[5][5],b[5][5],c[5][5],d[i][j],m,n,p,q,i,j,k; clrscr(); printf("\nEnter the number of rows and columns in matrix A"); scanf("%d%d",&m,&n); printf("\nEnter the elements into the matrix a"); for(i=0;i<m;i++) { for(j=0;j<n;j++) { scanf("%d",&a[i][j]); } } printf("\nEnter the number of rows and columns in matrix B"); scanf("%d%d",&p,&q); printf("\nEnter the elements into the matrix a"); for(i=0;i<p;i++) { for(j=0;j<q;j++) { scanf("%d",&b[i][j]); } } //Addition for(i=0;i<m;i++) { for(j=0;j<n;j++) { c[i][j]=a[i][j]+b[i][j]; } } //subtraction for(i=0;i<m;i++) { for(j=0;j<n;j++) { d[i][j]=a[i][j]-b[i][j]; } } for(i=0;i<m;i++) { for(j=0;j<n;j++) { printf("%d",c[i][j]); } }for(i=0;i<m;i++) { for(j=0;j<n;j++) { printf("%d",d[i][j]); } } getch(); }

  2. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Ask a Question
Find more explanations on OpenStudy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.