88.9k views
1 vote
Suppose that x is a double variable, y is an int variable, and ch is a char variable. The input is:

15A 73.2
Choose the values after the following statement executes:
cin >> x >> ch >> y;

a. x = 15, ch = 'A', y = 73.0
b. This statement results in an error because there is no space between 15 and A
c. x = 15, ch = 'A', y = 73.2
d. x = 15, ch = ‘a', y = 73.0

User Ancab
by
7.8k points

1 Answer

0 votes

Final answer:

The correct answer is: option c). x = 15, ch = 'A', y = 73.2.

Step-by-step explanation:

In the given input, x is assigned the value 15 because it is a double variable and can handle decimal numbers.

However, since ch is a char variable, it will only take the first character after the space, which is 'A'.

Finally, y is an int variable; despite the input being 73.2, only the integer part 73 is stored in y, with the decimal part discarded.

User Moltar
by
7.3k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.

9.4m questions

12.2m answers

Categories