i having trouble with writing this code. I am in a beginning C plus plus class.
ID: 3714478 • Letter: I
Question
i having trouble with writing this code. I am in a beginning C plus plus class. We are studying arrays and i am using Microsoft Visual Studios. with #include<iostream>,#include<iomanip>,#include<cmath>. I have to use arrays in order to write the code. thank u
thank you
Explanation / Answer
For first question:
For Second question:
/*
* C++ Program to compute 2*A + 3*B
*/
#include<iostream>
#include<math.h>
#include<conio.h>
using namespace std;
int main()
{
int m,n;
cout<<"enter the row of matrix" ;
cin>>m;
cout<<"enter the column of matrix" ;
cin>>n;
double mat1[10][10];
double mat2[10][10];
double mat3[10][10];
int i, j;
cout<<"enter the elements of A"<<endl;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cin>>mat1[i][j];
}
}
cout<<"enter the elements of B"<<endl;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cin>>mat2[i][j];
}
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
mat3[i][j]= 2 * mat1[i][j] + 3 * mat2[i][j];
}
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cout<<" " <<mat2[i][j]<<" ";
}
cout<<" ";
}
getch();
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.