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;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.