Using C write a subprogram to read N data items into each of
Using C++ write a subprogram to read N data items into each of two arrays ArayX and ArayY. Compare each of the elements of ArayX to the corresponding element of AraY. In the corresponding element of a third array ArayZ, store +1 if ArayX is larger than ArayY 0 if ArayX is equal to ArayY -1 if ArayX is less than ArayY
Solution
// C++ code
#include <iostream>
 #include <cstdio>
 #include <cmath>
 #include <cstring>
 #include <set>
 #include <vector>
 #include <map>
 #include <algorithm>
 #include <utility>
 #include <ctime>
 #include <limits.h>
using namespace std;
 int main()
 {
    int n;
    cout << \"Enter n: \";
    cin >> n;
float ArayX[n];
 float ArayY[n];
cout << \"Enter elements of ArayX: \";
 for(int i = 0; i < n; ++i)
 cin >> ArayX[i];
 cout << \"Enter elements of ArayY: \";
 for(int i = 0; i < n; ++i)
 cin >> ArayY[i];
float ArayZ[n];
 for (int i = 0; i < n; ++i)
 {
    if(ArayX[i] > ArayY[i])
        ArayZ[i] = 1;
    else if(ArayX[i] == ArayY[i])
        ArayZ[i] = 0;
    else
        ArayZ[i] = -1;
 }
cout << \"\ ArayZ values: \";
 for (int i = 0; i < n; ++i)
 {
    cout << ArayZ[i] << \" \";
 }
 cout << endl;
return 0;
 }
 /*
 output:
Enter n: 10
 Enter elements of ArayX: 3 4 5 1 4 7 5 8 5 6
 Enter elements of ArayY: 4 3 4 1 4 7 8 9 6 5
ArayZ values: -1 1 1 0 0 0 -1 -1 -1 1
*/


