Short Answer & Essay 1. (TCO 4) What is the output from the following loop if th
ID: 3629084 • Letter: S
Question
Short Answer & Essay1.
(TCO 4) What is the output from the following loop if the input is 5 10 2 3 -1 ?
int value = 1;
int input;
do
{
cin >> input;
value = value * input;
} while (input != -1);
cout << value * -1 << endl;
(Points : 5)
2. (TCO 3) A program has a char variable response that has been assigned a value. Write a switch statement that outputs "Yes" if the variable contains lower or upper case 'y', "No" if it contains lower or upper case 'n', or "Invalid Input" for any other value. (Points : 10)
3. (TCO 3) Assume a program has the following declarations and statements:
const int MAX = 100;
const int UPPER = 66;
const int LOWER = 33;
const int MIN = 0;
void main()
{
int score;
cin >> score;
//Add a few lines of code to do the following:
// For a score of UPPER to and including MAX, output "Well Done!"
// For a score of LOWER to but not including UPPER, output "Good Job."
// For a score of MIN to but not including LOWER output "Try Harder!"
// For any other score, output an error message.
(Points : 10)
Explanation / Answer
a)300 b) char ch; cin>>ch; switch(ch) { case'y': case'Y': coutRelated 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.