Quiz Entry - updated: 2026.06.23
What does >> do in C++ with cin?
>> is the stream extraction operator — it reads data from an input stream such as cin into a variable.
int n;
cout << "Enter n: ";
// Read integer typed by the user
cin >> n;
Key points:
cinis the standard input stream object>>automatically converts the text typed in to the variable's type (here, anint)- It skips leading whitespace by default
Equivalent in C:
int n;
printf("Enter n: ");
scanf("%d", &n);
Tip: Notice there's no & before n — unlike C's scanf, cin >> takes the variable by reference and handles the address itself.