C programing array problem Arrays keysList and itemsList are already-defined int
ID: 3564102 • Letter: C
Question
C programing array problem
Arrays keysList and itemsList are already-defined int types and initialized. Each is of size SIZE_LIST, already defined as int and initialized. For any element in keysList with a value greater than 100, print the corresponding value in itemsList followed by a space. Loop variable i has already been defined as type int. Example output if keysList is 42, 105, 101, 100 and if itemsList is 10, 20, 30, 40 is:
Since keysList[1] and keysList[2] have values greater than 100, the value of itemsList[1] and itemsList[2] are printed.
Below, do not type an entire program. Only type the portion indicated by the above instructions
Explanation / Answer
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
int keysList[] = {42, 105, 101, 100};
int itemsList[] = {10, 20, 30, 40};
int SIZE_LIST = 4;
for(int i = 0; i < SIZE_LIST; i++){
if(keysList[i] > 100){
printf("%d ",itemsList[i]);
}
}
return 0;
}
/*OutPut*/
20 30
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.