Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3. Consider the following C++ code: string str1; string str2; char ch; int index; cin >> str1; cin >> str2; cin >> index; ch =

3. Consider the following C++ code:

string str1;

string str2;

char ch;

int index;

cin >> str1;

cin >> str2;

cin >> index;

ch = str1[index];

str1[index] = str2[index];

str2[index] = ch;

cout << str1 << " " << 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?

4. Suppose that you have the following statements:

string str1, str2;

cin >> str1 >> str2;

if (str1 == str2)

cout << str1 + '!' << endl;

else if (str1 > str2)

cout << str1 + " > " + str2 << endl;

else

cout << str1 + " < " + 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?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Carlos Coronel, Steven Morris

14th Edition

978-0357673034

More Books

Students also viewed these Databases questions

Question

Define and explain the goals of employee orientation/onboarding

Answered: 1 week ago