Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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 'cout

Explanation / 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....
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote