Question
![Given the following set of code, select all C++ expressions:
4₁
#include <iostream>
#include <sstream>
#include <vector>
#include "grocery_list_lib.h"
// Returns an array of pair objects of item and amount
std::array<std::pair<std::string, double>, 5> create_grocery_list (){
std::array<std::pair<std::string, double>, 5 grocery_list;
std::string item;
std::string item_amount;
F3
double amount;
for(int i = 0; i < 5; i++){
std::cout << "Enter item: "
getline(std::cin, item);
grocery_list[i].first = item;
getline(std::cin, item_amount);
std::stringstream(item_amount) >> amount
grocery_list[i].second = amount;
}
return grocery_list;
}
grocery_list[i].first
std::string item;
item_amount
return grocery_list;
"Enter item:
$
4
4)
R
Q Search
DII
%
5
T
F5
6
LO
F6
Y
F7
&
7
U
BO
PrtScn
F8
8
Home
F9
9
End
F10
Po
0](https://content.bartleby.com/qna-images/question/22b1319c-242c-4915-8f56-7c035e43f773/dd7acd2f-7311-4f32-8cba-24e910bc9c49/qd71a4_thumbnail.jpeg)
Transcribed Image Text:Given the following set of code, select all C++ expressions:
4₁
#include <iostream>
#include <sstream>
#include <vector>
#include "grocery_list_lib.h"
// Returns an array of pair objects of item and amount
std::array<std::pair<std::string, double>, 5> create_grocery_list (){
std::array<std::pair<std::string, double>, 5 grocery_list;
std::string item;
std::string item_amount;
F3
double amount;
for(int i = 0; i < 5; i++){
std::cout << "Enter item: "
getline(std::cin, item);
grocery_list[i].first = item;
getline(std::cin, item_amount);
std::stringstream(item_amount) >> amount
grocery_list[i].second = amount;
}
return grocery_list;
}
grocery_list[i].first
std::string item;
item_amount
return grocery_list;
"Enter item:
$
4
4)
R
Q Search
DII
%
5
T
F5
6
LO
F6
Y
F7
&
7
U
BO
PrtScn
F8
8
Home
F9
9
End
F10
Po
0
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps

Knowledge Booster
Similar questions
- C++ programming task. main.cc file: #include <iostream>#include <map>#include <vector> #include "plane.h" int main() { std::vector<double> weights{3.2, 4.7, 2.1, 5.5, 9.8, 7.4, 1.6, 9.3}; std::cout << "Printing out all the weights: " << std::endl; // ======= YOUR CODE HERE ======== // 1. Using an iterator, print out all the elements in // the weights vector on one line, separated by spaces. // Hint: see the README for the for loop syntax using // an iterator, .begin(), and .end() // ========================== std::cout << std::endl; std::map<std::string, std::string> abbrevs{{"AL", "Alabama"}, {"CA", "California"}, {"GA", "Georgia"}, {"TX", "Texas"}}; std::map<std::string, double> populations{ {"CA", 39.2}, {"GA", 10.8}, {"AL", 5.1}, {"TX", 29.5}}; std::cout <<…arrow_forwardC++ languagearrow_forwardinitial c++ file/starter code: #include <vector>#include <iostream>#include <algorithm> using namespace std; // The puzzle will always have exactly 20 columnsconst int numCols = 20; // Searches the entire puzzle, but may use helper functions to implement logicvoid searchPuzzle(const char puzzle[][numCols], const string wordBank[],vector <string> &discovered, int numRows, int numWords); // Printer function that outputs a vectorvoid printVector(const vector <string> &v);// Example of one potential helper function.// bool searchPuzzleToTheRight(const char puzzle[][numCols], const string &word,// int rowStart, int colStart) int main(){int numRows, numWords; // grab the array row dimension and amount of wordscin >> numRows >> numWords;// declare a 2D arraychar puzzle[numRows][numCols];// TODO: fill the 2D array via input// read the puzzle in from the input file using cin // create a 1D array for wodsstring wordBank[numWords];// TODO:…arrow_forward
- #include <iostream> #include <iomanip> #include <string> #include <vector> using namespace std; class Movie { private: string title = ""; int year = 0; public: void set_title(string title_param); string get_title() const; // "const" safeguards class variable changes within function string get_title_upper() const; void set_year(int year_param); int get_year() const; }; // NOTICE: Class declaration ends with semicolon! void Movie::set_title(string title_param) { title = title_param; } string Movie::get_title() const { return title; } string Movie::get_title_upper() const { string title_upper; for (char c : title) { title_upper.push_back(toupper(c)); } return title_upper; } void Movie::set_year(int year_param) { year = year_param; } int Movie::get_year() const { return year; } int main() { cout << "The Movie List program\n\n"…arrow_forwardIn C++ Assume that a 5 element array of type string named boroughs has been declared and initialized. Write the code necessary to switch (exchange) the values of the first and last elements of the array.arrow_forwardin C code not c++arrow_forward
arrow_back_ios
arrow_forward_ios