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