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/elementfrom 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. Displayelements/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#includeusing 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="">"****><> //read array1 values for(index=0;index<> { cout<"enter element="" in="" array1="" at="" index="">"enter><><" =="" "="">"> cin>>array1[index]; } cout<"****\nsecond array="">"****\nsecond><> //read array2 values for(index=0;index<> { cout<"enter element="" in="" array2="" at="" index="">"enter><><" =="" "="">"> cin>>array2[index]; } //copy array1 to array3 for(index=0;index<> { array3[index]=array1[index]; } //copy array2 to array4 for(index=0;index<> { array4[index]=array2[index]; } //display array3 values cout<"\ndisplaying elements="" of="">"\ndisplaying><> for(index=0;index<> cout<><">"> //display array4 values cout<"\ndisplaying elements="" of="">"\ndisplaying><> for(index=0;index<> cout<><">"> system("pause"); return 0;}Output:Extracted text: **** First Array **** Enter element in arrayl at index 0 32 Enter element in arrayl at index 1 4 Enter element in arrayl at index 2 5 Enter element in arrayl at index 3 6 Enter element in arrayl at index 4 8 Enter element in arrayl at index 5 7 Enter element in arrayl at index 6 9 Enter element in arrayl at index 7 6 Enter element in arrayl at index 8 10 Enter element in arrayl at index 9 12 Enter element in arrayl at index 10 13 **** Second Array **** Enter element in array2 at index 0 12 Enter element in array2 at index 1 14 Enter element in array2 at index 2 366 34 Enter element in array2 at index 3 Enter element in array2 at index 4 6 Enter element in array2 at index 5 Enter element in array2 at index 6 Enter element in array2 at index 7 Enter element in array2 at index 8 14 Enter element in array2 at index 9 15 Enter element in array2 at index 10 = 16 Displaying elements of array3 32 4 5 6 8 7 9 6 10 12 13 Displaying elements of array4 12 14 366 34 5 6 10 13 14 15 16 Press any key to continue . 034L || || || || || || || || || || || || || || || || ||
cout<"**** first="" array="">"****><> //read array1 values for(index=0;index<> { cout<"enter element="" in="" array1="" at="" index="">"enter><><" =="" "="">"> cin>>array1[index]; } cout<"****\nsecond array="">"****\nsecond><> //read array2 values for(index=0;index<> { cout<"enter element="" in="" array2="" at="" index="">"enter><><" =="" "="">"> cin>>array2[index]; }
//copy array1 to array3 for(index=0;index<> { array3[index]=array1[index]; } //copy array2 to array4 for(index=0;index<> { array4[index]=array2[index]; } //display array3 values cout<"\ndisplaying elements="" of="">"\ndisplaying><> for(index=0;index<> cout<><">"> //display array4 values cout<"\ndisplaying elements="" of="">"\ndisplaying><> for(index=0;index<> cout<><">">
system("pause"); return 0;}
Output:
Extracted text: **** First Array **** Enter element in arrayl at index 0 32 Enter element in arrayl at index 1 4 Enter element in arrayl at index 2 5 Enter element in arrayl at index 3 6 Enter element in arrayl at index 4 8 Enter element in arrayl at index 5 7 Enter element in arrayl at index 6 9 Enter element in arrayl at index 7 6 Enter element in arrayl at index 8 10 Enter element in arrayl at index 9 12 Enter element in arrayl at index 10 13 **** Second Array **** Enter element in array2 at index 0 12 Enter element in array2 at index 1 14 Enter element in array2 at index 2 366 34 Enter element in array2 at index 3 Enter element in array2 at index 4 6 Enter element in array2 at index 5 Enter element in array2 at index 6 Enter element in array2 at index 7 Enter element in array2 at index 8 14 Enter element in array2 at index 9 15 Enter element in array2 at index 10 = 16 Displaying elements of array3 32 4 5 6 8 7 9 6 10 12 13 Displaying elements of array4 12 14 366 34 5 6 10 13 14 15 16 Press any key to continue . 034L || || || || || || || || || || || || || || || || ||
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here