Jump to level 1 Subtract each element in origList with the corresponding value in offsetAmount. Print each difference followed by a space. Ex: If origList = {4, 5, 10, 12} and offsetAmount = {2, 4, 7, 3}, print: 2 1 3 9 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 #include #include using namespace std; int main() { const int NUM_VALS = 4; int origList[NUM_VALS]; int offsetAmount[NUM_VALS]; int i; cin >> origList[0]; cin >> origList[1]; cin >> origList[2]; cin >> origList[3]; cin >> offsetAmount[0]; cin >> offsetAmount[1]; cin >> offsetAmount[2]; cin >> offsetAmount[3]; /* Your code goes here */ cout << endl; return 0; } 1 2 Check Next

Respuesta :

Answer:

#include <stdio.h>

int main() {

   const int NUM_VALS = 4;

   int origList[NUM_VALS];

   int offsetAmount[NUM_VALS];

   int i;

   origList[0] = 40;

   origList[1] = 50;

   origList[2] = 60;

   origList[3] = 70;

   offsetAmount[0] = 4;

   offsetAmount[1] = 6;

   offsetAmount[2] = 2;

   offsetAmount[3] = 8;

   for (i = 0; i < NUM_VALS; ++i) {

       printf("%d ", origList[i] - offsetAmount[i]);

   }

   printf("\n");

   return 0;

}

Explanation:

  • After writing all the code given in the question, run a for loop until the variable i is less than the value of NUM_VALS constant.
  • In other words, the for loop will be executed 4 times as the value of NUM_VALS constant is equal to 4.
  • Inside the for loop display the results by subtracting offsetAmount from origList.