Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using for loop construct and the cin to create a C++ program employing [2] 5 uni

ID: 3569066 • Letter: U

Question

Using for loop construct and the cin to create a C++ program employing [2] 5 unit element interger fields, named First Array and Second Array.

The array print out should be called Sum Of Arrays, which elements show the sum of the elements of the two initial arrays.

Print result output as the following table (same screen):

First Array

Address of

Second Array

Address of

First Element

Second Element

Third Element

Four ELement

Fifth Element

First Array

Address of

Second Array

Address of

First Element

Second Element

Third Element

Four ELement

Fifth Element

Explanation / Answer

#include <iostream>
#include <iomanip>
using namespace std;

int main() {

   int FirstArray[5];
   int SecondArray[5];
int sumOfArrays[5];

cout<<"Enter 5 elements for First Array with spaces: ";
   for(int i=0; i<5; i++)
{
   cin>>FirstArray[i];
}
cout<<" ";
cout<<"Enter 5 elements for Second Array with spaces: ";
   for(int i=0; i<5; i++)
{
   cin>>SecondArray[i];
}
//first part

   for(int i=0; i<5; i++)
{
sumOfArrays[i] = FirstArray[i] + SecondArray[i];
}
cout<<" Sum of arrays: ";
   for(int i=0; i<5; i++)
{
cout<<sumOfArrays[i]<<" ";
}
cout<<" ";

//second part
cout<<setw(15)<<""<<setw(15)<<"First Array"<<setw(15)<<"Address Of"<<setw(15)<<"Second Array"<<setw(15)<<"Address Of"<<" ";
   for(int i=0; i<5; i++)
{
if(i==0)
cout<<setw(15)<<"First Element";

if(i==1)
cout<<setw(15)<<"Second Element";

if(i==2)
cout<<setw(15)<<"Third Element";

if(i==3)
cout<<setw(15)<<"Fourth Element";

if(i==4)
cout<<setw(15)<<"Fifth Element";

cout<<setw(15)<<FirstArray[i]<<setw(15)<<&FirstArray[i]<<setw(15)<<SecondArray[i]<<setw(15)<<&SecondArray[i]<<" ";
}

   return 0;
}

------------------------------------------------------------------

OUTPUT

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote