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

//File: 1170_10_5.cc //Purpose: This program displays the appropriate color depe

ID: 3655746 • Letter: #

Question

//File: 1170_10_5.cc //Purpose: This program displays the appropriate color depending on the value // of a variable colorval as below: // if colorval is print this color // 1 red // 2 blue // 3 green // 4 yellow // all other value unknown //include files... #include #include using namespace std; int main() { int colorval; //value of a color string color; // input colorval cout << "Enter the value of a color variable (1-4): "; cin >> colorval; switch Complete the switch statement started above that assigns the appropriate color depending on the value of a variable colorval as following: // 1 red // 2 blue // 3 green // 4 yellow // all other value unknown Complete the switch statement started above that assigns the appropriate color depending on the value of a variable colorval as following: // 1 red // 2 blue // 3 green // 4 yellow // all other value unknown cout << "The color is " << color << endl; return 0; }

Explanation / Answer

/*include string.h header file*/ #include#include#includeusing namespace std; int main() { int colorval; char color[8]; cout > colorval; switch(colorval) { case 1: strcpy(color,"RED"); break; case 2: strcpy(color,"BLUE"); break; case 3: strcpy(color,"GREEN"); break; case 4: strcpy(color,"YELLOW"); break; default :strcpy(color,"UNKNOWN"); break; } cout