1) #include <stdio.h> int main(void) { const int NUM_VALS = 4; int origList[NUM_
ID: 644545 • Letter: 1
Question
1)
#include <stdio.h>
int main(void) {
const int NUM_VALS = 4;
int origList[NUM_VALS];
int offsetAmount[NUM_VALS];
int i = 0;
origList[0] = 40;
origList[1] = 50;
origList[2] = 60;
origList[3] = 70;
offsetAmount[0] = 5;
offsetAmount[1] = 7;
offsetAmount[2] = 3;
offsetAmount[3] = 0;
/* Your solution goes here */
printf(" ");
return 0;
}
2)For any element in keysList with a value greater than 100, print the corresponding value in itemsList, followed by a space. Ex: If keysList = {42, 105, 101, 100} and itemsList = {10, 20, 30, 40}, print:
Since keysList[1] and keysList[2] have values greater than 100, the value of itemsList[1] and itemsList[2] are printed.
#include <stdio.h>
int main(void) {
const int SIZE_LIST = 4;
int keysList[SIZE_LIST];
int itemsList[SIZE_LIST];
int i = 0;
keysList[0] = 42;
keysList[1] = 105;
keysList[2] = 101;
keysList[3] = 100;
itemsList[0] = 10;
itemsList[1] = 20;
itemsList[2] = 30;
itemsList[3] = 40;
/* Your solution goes here */
printf(" ");
return 0;
}
45 57 63 70
Explanation / Answer
#include <stdio.h>
int main(void) {
const int NUM_VALS = 4;
int origList[NUM_VALS];
int offsetAmount[NUM_VALS];
int i = 0;
origList[0] = 40;
origList[1] = 50;
origList[2] = 60;
origList[3] = 70;
offsetAmount[0] = 5;
offsetAmount[1] = 7;
offsetAmount[2] = 3;
offsetAmount[3] = 0;
for(i = 0; i < NUM_VALS; ++i){
printf("%d ", origList[i] + offsetAmount[i]);
}
printf(" ");
return 0;
}
__________________________________________________________________________
#include <stdio.h>
int main(void) {
const int SIZE_LIST = 4;
int keysList[SIZE_LIST];
int itemsList[SIZE_LIST];
int i = 0;
keysList[0] = 42;
keysList[1] = 105;
keysList[2] = 101;
keysList[3] = 100;
itemsList[0] = 10;
itemsList[1] = 20;
itemsList[2] = 30;
itemsList[3] = 40;
for(i = 0; i < SIZE_LIST; ++i){
if(keysList[i] > 100){
printf("%d ", itemsList[i]);
}
}
printf(" ");
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.