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

. Answer the questions that follow given these lines of code. string str1, str2;

ID: 1925604 • Letter: #

Question

. Answer the questions that follow given these lines of code.

string str1, str2;

cin >> str1 >> str2;
if(str1 == str2)
{
cout << str1 << " == " << str2 << endl;
}
else if (str1 > str2)
{
cout << str1 << " > " << str2 << endl;
}
else
{
cout << str1 << " < " str2 << endl;
}

a. What do these lines output if the input is "diamond diamond"?

b. What do these lines output if the input is "diamond gold"?

c. What do these lines output if the input is "silver gold"?

Explanation / Answer

a) diamond == diamond b) diamond gold