ACTIV15.4.1: Multiple arrays Reset Subtract each element in origList with the co
ID: 3728788 • Letter: A
Question
ACTIV15.4.1: Multiple arrays Reset 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 39 4 5 int main) const int NUM-VALS = 4; 7 int origList[NUM VALS]; 8 int offsetAmount [NUM VALS]; 9 int i; 10 11 origlist[0] 20; 12 origList[1] = 30 ; 13 origList[2] = 40 ; 14 origList[3] = 50; 15 16 offsetAmount[0]=5; 17 offsetAmount[1] = 7; 18 offsetAmount[2] = 3; 19 offsetAmount[3] 4; 20 21 * Your solution goes here/Explanation / Answer
#include<stdio.h>
int main()
{
const int NUM_VALS = 4;
int origList[NUM_VALS];
int offsetAmount[NUM_VALS];
int i;
origList[0] = 20;
origList[1] = 30;
origList[2] = 40;
origList[3] = 50;
offsetAmount[0] = 5;
offsetAmount[1] = 7;
offsetAmount[2] = 3;
offsetAmount[3] = 4;
for(int i=0; i<NUM_VALS; i++)
printf("%d ", origList[i] - offsetAmount[i]);
printf(" ");
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.