Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please type in C++: #include #include using namespace std; int main() { int numElements; string foodAsked; unsigned int i; cin >> numElements; vector foodList(numElements); vector
Please type in C++:
#include
int main() { int numElements; string foodAsked; unsigned int i;
cin >> numElements;
vector
for (i = 0; i > foodList.at(i); cin >> labelList.at(i); }
cin >> foodAsked;
/* Your code goes here */
return 0; }
Integer numElements is read from input. Then, strings and integers are read and stored into string vector foodList and integer vector labelList, respectively. Lastly, string foodAsked is read from input. Find foodAsked in foodList and output the following: - "The food " - the value of foodAsked - "has value" - the element in labelList at the index of foodAsked in foodList - " and is at index " - the index of foodAsked in foodList End with a newline. Ex: If the input is: 4 onion 16 guava 44 corn 89 cabbage 73 corn Then the output is: The food corn has value 89 and is at index 2 Note: foodAsked is an element in foodListStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started