11.7k views
2 votes
Assume user_name equals "Tom" and user_age equals 22. What is printed on the console when the following statement is executed? cout << user_age << " \\is " + user_name << "'s age.";

1 Answer

5 votes

Answer:

The ouput of the given code is :

22

is "Tom's age.

Step-by-step explanation:

Here in this code the variable user_name and user_age are initialized to "Tom" and 22 respectively as statement is given in the question i.e cout << user_age << " \\is " + user_name << "'s age.";.This line will print the user_age i.e 22 after that the control moves to the next line and print is "Tom's age.

Following are the code in c++

#include <iostream> // header file

#include <string>

using namespace std;

int main() // main function

{

string user_name="Tom";

int user_age= 22;

cout << user_age << " \\is " + user_name << "'s age.";

return 0;

}

Output:

22

is "Tom's age.

User Wiesson
by
5.6k points