Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

XoOo13

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