Ask the User

Get user input from the console using cin.

You’ve printed messages. You’ve stored the text. Now, it’s time for your program to listen. In this lesson, you’ll use cin to get user input from the keyboard.

Goal

You’ll aim to:

  • Use cin to take input.

  • Store input in variables.

  • Build interactive programs that react to users.

Ask for a name

Here’s how cin works in C++:

Get hands-on with 1400+ tech skills courses.