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

QUESTION 12 What will this code display? int a(4); int b(10); int c(6); for (int

ID: 3675504 • Letter: Q

Question

QUESTION 12

What will this code display?

int a(4);

int b(10);

int c(6);

for (int i(0); i<5; i+=2)

{

if (a%2 == 1)

{ a+=i; }

else

{ --a; }

}

if (a>b)

{ cout << "1" << " "; }

else

{

if (a +c > b)

{ cout << "2" << " "; }

else

{ cout << "3" << " " ; }

}

while (a<b)

{

cout << b-a << " ";

a +=2;

}

1 2

2 3 1

2 1

2 3

You are writing a code that plays your favorite song everytime it is 5:00AM. You have an input feed that provides you with the current time. Which structure will you utilize in your code? Select all that apply.

if-else

while loop

Switch

for loop

A.

1 2

B.

2 3 1

C.

2 1

D.

2 3

Explanation / Answer

Q12. Ans: C - 2, 1

Since favorite song will play at 5.00 PM. So, if time is given to me, then i will first check whether it is 5 AM or not.

So, case statements will be used.

Ans: if-else, switch

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