C++ must be done in microsoft visual studio Create a 3 by 4 two dimensional arra
ID: 3724647 • Letter: C
Question
C++ must be done in microsoft visual studio
Create a 3 by 4 two dimensional array and fill it with the following numbers 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22 Create a second 3 by 4 two dimensional array and will it with the following numbers: 1, 2, 4,6, 8, 10, 12, 14, 16, 18, 20, 22 Create a third 3 by 4 array and use for loops to generate and hold the values of the second array subtracted from the first array. You must do this with an algorithm, it cannot be hard coded in this third array. Output all three two dimensional arrays to the screen in a manner that looks like three separate tables or matrixes.Explanation / Answer
#include <iostream>
using namespace std;
int main()
{
int arr1[3][4], arr2[3][4], arr3[3][4], sub, i, j;
cout<<"Enter 3*4 Array 1 Elements : ";
for(i=0; i<3; i++)
{
for(j=0; j<4; j++)
{
cin>>arr1[i][j];
}
}
cout<<"Enter 3*4 Array 2 Elements : ";
for(i=0; i<3; i++)
{
for(j=0; j<4; j++)
{
cin>>arr2[i][j];
}
}
cout<<"Subtracting array (array1-array2) ... ";
for(i=0; i<3; i++)
{
for(j=0; j<4; j++)
{
arr3[i][j]=arr1[i][j]-arr2[i][j];
}
}
cout<<"Array1 is : ";
for(i=0; i<3; i++)
{
for(j=0; j<4; j++)
{
cout<<arr1[i][j]<<" ";
}
cout<<" ";
}
cout<<"Array2 is : ";
for(i=0; i<3; i++)
{
for(j=0; j<4; j++)
{
cout<<arr2[i][j]<<" ";
}
cout<<" ";
}
cout<<"Result of Array1 - Array2 is : ";
for(i=0; i<3; i++)
{
for(j=0; j<4; j++)
{
cout<<arr3[i][j]<<" ";
}
cout<<" ";
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.