BLACK FRIDAY SALE – Unlock Up to 25% OFF on All Exam Prep! - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

C++ Institute CPP Exam - Topic 1 Question 130 Discussion

Posted by Adolph on Oct 16, 2026 at 04:04 AM

What will happen when you attempt to compile and run the code below, assuming that you enter the following sequence: one two three?

#include

#include

using namespace std;

int main ()

{

string a;

cin>>a;

cout<

return 0;

}

Program will output:

Suggested Answer: A

Get Premium CPP Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
10 comments · newest first
MA
Margery 3 hours ago
I think it will output A) one.
BA
Barney 5 days ago
Compilation is fine, just a simple input!
PA
Paola 10 days ago
Nope, no runtime exception here.
EU
Eun 16 days ago
Wait, really? I thought it would take the whole line!
KI
Kiera 21 days ago
Totally agree, just the first word gets read.
WA
Walton 26 days ago
It will output "one".
OL
Olive 1 month ago
I’m pretty confident it will compile fine, but I’m torn between A and B for the output.
VI
Virgina 1 month ago
I feel like there might be a runtime exception, but that seems unlikely for this simple input.
EL
Elmira 1 month ago
I'm not entirely sure, but I remember a similar question where only the first word was captured.
BE
Bernadine 2 months ago
I think the program will only output "one" since cin stops reading at the first space.
0/2000 characters

Save Cancel