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

QUESTION 4 The following code can compile but a keyword is missing in the the st

ID: 3675503 • Letter: Q

Question

QUESTION 4

The following code can compile but a keyword is missing in the the structure; which of the following keywords should replace case 'I' ?

char l = 'A';

switch(l)

{

case 'D': cout << "Democrat ";

case 'R': cout << "Republican ";

case 'I': cout << " Independent ";

}

if

break:

case else:

default:

10 points   

QUESTION 5

Consider this code, after modification to its correct format (In that order, one statement needs change). When char l = 'A', what will be displayed?

char l;

switch(l)

{

case 'D': cout << "Democrat ";

case 'R': cout << "Republican ";

case 'I': cout << " Independent ";

}

When char l = 'A', what will be displayed?

if

break:

default:

case else:

10 points   

QUESTION 6

Consider the following piece of code:

int main ()

{

int n = 5;

char letter;

while (n-1 > 0)

{cout << n << " ";

--n;

}

cout << " Enter a letter to exit ";

cin >> letter;

return 0;

}

Which of the following will be displayed?

5 4 3 2

4 3 2

5 4 3 2 1

4 3 2 1

A.

if

B.

break:

C.

case else:

D.

default:

Explanation / Answer

Q4.   'break' is missing from structure
   'defualt' keyword can replace case 'l'
   char l = 'A';
   switch(l)
   {
   case 'D': cout << "Democrat ";
               break;
   case 'R': cout << "Republican ";
               break;
   default: cout << " Independent ";

   }
  
Q5. Independent -- see above modified code in Q4

Q6.   5 4 3 2

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