Only Explain, How this C++ Program is working, Write brief Description. Just For Understanding Program Requirements Here's The Statement: Create 4 arrays of type integer having the size of 11 and assign values to only 2 arrays using for loop. • Once values are assigned to 2 arrays then you have to copy the values/element from both arrays and assign/paste those values to the third and fourth array. • After assigning values to the third and fourth array from the first and second array. Display elements/values of array3 and array4. • Array2 elements/values will be copied to array4. In the end the array 3 and array4 will have the same elements/values as array1 and array2. Briefly Explain only, how it's working. Source code: //main.cpp #include using namespace std; int main() { //set the N=11 as constant const int N=11; int array1[N]; int array2[N]; int array3[N]; int array4[N]; int index; cout<<"**** First Array ****"<
Only Explain, How this C++ Program is working, Write brief Description.
Just For Understanding Program Requirements
Here's The Statement:
Create 4 arrays of type integer having the size of 11 and assign values to only 2 arrays using for loop.
• Once values are assigned to 2 arrays then you have to copy the values/element
from both arrays and assign/paste those values to the third and fourth array.
• After assigning values to the third and fourth array from the first and second array. Display
elements/values of array3 and array4.
• Array2 elements/values will be copied to array4.
In the end the array 3 and array4 will have the same elements/values as array1 and array2.
Briefly Explain only, how it's working.
Source code:
//main.cpp
#include<iostream>
using namespace std;
int main()
{
//set the N=11 as constant
const int N=11;
int array1[N];
int array2[N];
int array3[N];
int array4[N];
int index;
cout<<"**** First Array ****"<<endl;
//read array1 values
for(index=0;index<N;index++)
{
cout<<"Enter element in array1 at index "
<<index<<" = " ;
cin>>array1[index];
}
cout<<"****\nSecond Array ****"<<endl;
//read array2 values
for(index=0;index<N;index++)
{
cout<<"Enter element in array2 at index "
<<index<<" = " ;
cin>>array2[index];
}
//copy array1 to array3
for(index=0;index<N;index++)
{
array3[index]=array1[index];
}
//copy array2 to array4
for(index=0;index<N;index++)
{
array4[index]=array2[index];
}
//display array3 values
cout<<"\nDisplaying elements of array3"<<endl;
for(index=0;index<N;index++)
cout<<array3[index]<<" ";
//display array4 values
cout<<"\nDisplaying elements of array4"<<endl;
for(index=0;index<N;index++)
cout<<array4[index]<<" ";
system("pause");
return 0;
}
Output:
Step by step
Solved in 3 steps