suppose that x is an int variable, y is a double variable and ch is a char variable and 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.2
b. x=15, ch='A', y=73.0
c. x=15, ch='a', y=73.0
d. this statement results in an error because there is no space between 15 and A.

I think it is d because there should be a space between the two. if anyone could let me know i would appreciate it. thanks

Recommended Answers

All 4 Replies

why don't you compile it and see for yourself what the answer is.

Let's use some multiple choice logic, shall we?

1) The likelihood of (d) is minimal, otherwise there would be similar choices.
2) (c) can be ruled out because (a) and (b) both have the same value for ch.

This logic rules the options down to deciding between .2 or .0.

thanks

thank, you i will

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.