Input and Output with cin/cout
C++ uses cin
for input and cout
for output. They are part of the iostream
library.
#include <iostream>
using namespace std;
int main() {
int age;
cout << "Enter your age: ";
cin >> age;
cout << "You are " << age << " years old.";
return 0;
}
cout
uses the insertion operator <<
, and cin
uses the extraction operator >>
.