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

15. Consider the following C++ code: string strl; string str2; char ch; int inde

ID: 3762883 • Letter: 1

Question

15. Consider the following C++ code: string strl; string str2; char ch; int index;

cin >> strl; cin >> str2; cin >> index;

ch = strl[index]; strl[index] = str2[index]; str2[index] = ch;

cout << strl << " " << str2 << endl;

Answer the following questions:

a. What is the output if the input is Hello There 2?

b. What is the output if the input is Diamond Gold 0?

c. What is the output if the input is C++ Java 1?

16. Suppose that you have the following statements:

string strl, str2;

cin >> strl >> str2;

if (strl == str2) cout << strl + ' !' << endl;

else if (strl > str2) cout << strl + " > " + str2 << endl;

else cout << strl + " < " + str2 << endl;

Answer the following questions:

a. What is the output if the input is Programming Project?

b. What is the output if the input is Summer Trip?

c. What is the output if the input is Winter Cold?

Explanation / Answer

15. a) Heelo Thlre

b) Giamond Dold

c) Ca+ J+va

16. a) Programming > Project

b) Summer < Trip

c) Winter > Cold

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote