(C++ program) Use the code segment below to
answer the two questions that follow.
…
int size = 0;
cout << “Enter size: “;
cin >> size;
int sizeCode = size / 10;
if (sizeCode == 0)
cout << “extra small”;
else if(sizeCode == 1 )
cout << “small”;
else if (sizeCode == 2)
cout << “medium”;
else if (sizeCode == 3)
cout << “large”;
else
cout << “extra large”;
//end if
…
What would the code display when the size variable contains the value 35?
What would the code display when the size variable contains the value 9?
Rewrite the code in part a above using the switch statement. The new code should have the same functionality as the previous one.
the code display when the size variable contains the value 35 is large the code display when the size variable contains the value 9 is extra small the code in part a above using the switch statement is int size = 0; cout << “Enter size: “; cin >> size; int sizeCode = size / 10; switch(sizeCode){ case 0: cout << “extra small”; break; case 1: cout << “small”; break; case 2: cout << “medium”; break; case 3: cout << “large”; break; default: cout << “extra large”; }
Get Answers For Free
Most questions answered within 1 hours.