Write a program that creates two integer arrays of sizes N and M, respectively. These arrays can be initialized within the code (no need to get values as input from the user). Then, create a third array of size N+M (i.e., whose size should be equal to the sum of the sizes of the first and the second array) and copy the elements of both (first and second) arrays into the third array. Finally, print the values of all the three arrays, as shown below: 

Sample Output:

programming exercise with solution
programming exercise with solution


#include <iostream>
using namespace std;

void Arr()
{
    int arr[5] = {1,2,3,4,5};
    int arr2[8] = {10,20,30,40,50,80,62, 56};
    int arr3[13];
    int k = 0;
   

    cout<<"\nThe values of first array: ";
    for (int i = 0; i < 5; i++)
    {
        arr3[k++] = arr[i];
        cout<<arr[i]<<" ";      
    }

    cout<<endl<<"The values of second array: ";
    for (int i = 0; i < 8; i++)
    {
        arr3[k++] = arr2[i];
        cout<<arr2[i]<<" ";        
    }

    cout<<endl<<"The values of third array: ";
    for (int i = 0; i < 13; i++)
    {
        cout<<arr3[i]<<" ";
    }
}
int main()
{
    Arr();
    return 0;
}