Respuesta :
Answer:
- #include <iostream>
- using namespace std;
- int main()
- {
- const int SIZE_LIST = 4;
- int keysList[SIZE_LIST];
- int itemsList[SIZE_LIST];
- int i;
- keysList[0] = 13;
- keysList[1] = 47;
- keysList[2] = 71;
- keysList[3] = 59;
- itemsList[0] = 12;
- itemsList[1] = 36;
- itemsList[2] = 72;
- itemsList[3] = 54;
- for(i=0; i < SIZE_LIST; i++){
- if(keysList[i] < 40){
- cout<<itemsList[i]<< " ";
- }
- }
- return 0;
- }
Explanation:
In the given code we have two parallel arrays with predefined values (Line 11 - 18). To check if any value from keysList below 40, create a for loop to traverse through the array and in the loop create an if statement to check the each of the keysList value (Line 20 - 22). If any value from keysList is below 40, use the current i value as an index to get the corresponding value from itemsList (Line 23) and print it out along with a single space " ".