A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing


  • 3 years 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. anonymous
    • 3 years 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

Sign Up
Find more explanations on OpenStudy
Privacy Policy

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...


  • 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.