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

Modify the code below so that it displays: apples oranges bananas pineapple when

ID: 3545222 • Letter: M

Question

Modify the code below so that it displays:


apples

oranges

bananas

pineapple


when n1=1 and n2=2


AND


apples

bananas

pineapple


when n1 = 1 and n2 =/= 2 (n2 does NOT equal to 2, sorry about that)


You must not make any changes other than inserting opening {{ ) and closing ( }} braces and indenting the code.


//Code to modify


if (n1 == 1)


cout << "apples" << endl;


if (n2 == 2)


cout << "oranges" << endl;


cout << "bananas" << endl;


else


cout << "kiwis" << endl;


cout << "pineapple" << endl;

Explanation / Answer

if (n1 == 1)

{


cout << "apples" << endl;



if (n2 == 2)


cout << "oranges" << endl;



}




else

cout << "kiwis" << endl;



cout << "bananas" << endl;


cout << "pineapple" << endl;

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