3. Suppose a user would like to output the name \"Sarah\" to the screen, and the
ID: 3919235 • Letter: 3
Question
3. Suppose a user would like to output the name "Sarah" to the screen, and they have written the following code in an attempt to do so: #include iostream» using namespace std; int mainc) son students Mike, Sarah, Steve, Alexis, Nuri, Patcicia sou???students(1)??snal; A. Which of the following modifications will ensure that Sarah's name will be printed to the screen? (3 points) Initialize a string to the value of each student and then output it to the screen: Students(1); string Sarah sau??? Sarah; ii.Write (and call with Sarah as the input parameter following 'coutExplanation / Answer
Question 3
Ans) ii will work.
Explanation:-
//Header files for I/O and string
#include<iostream>
#include<string>
using namespace std;
//Enum declaration
enum students { Mike, Sarah, Steve, Alexis, Nuri, Patricia };
//Function prototype
string outputName(students x);
int main()
{
//Call function
cout << outputName(Sarah) << endl;
return 0;
}
//Function definition
string outputName(students x) {
if (x == Sarah) {
return "Sarah";
}
//etc....
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.