Skip to content

Reading numbers with cin

Read · 1 of 4

cin is the opposite of cout

cout << x sends a value out to the screen. cin >> x takes the next value typed in and stores it in x.

In DSA problems the input is given to your program, and you print only the answer. No "Enter a number:" messages: they'd make your output wrong.