Third, the input statement
We've learned the output statement cout, which we'll learn about the input statement cin (read as c-in), let's take a look at an exercise;
1, start Geany
1 point Menu "application-programming-geany" Start Geany, create a new C + + source program;
2 Point Menu "file-Save as" command, to "Shuru" as the filename, save the file to its own folder;
2, input program code
1 in the Blue Code area below, enter the following statement:
int a = 0;
cout << "input A:";
Cin >> A;
cout << "A=" << A;
2 The first line defines an integer variable A and assigns a value of 0.
The second line shows a hint, the third line executes the input statement (read as c-in), and line fourth shows the contents of the variable a at this time;
3 save, compile, build, run, first come out a line of hints, a flash of the cursor, request a number of input;
4 then press the keyboard, enter 20 and then click the Enter key, which shows that the value of the variable A is already 20;
5 The CIN statement can also enter multiple numbers, such as: Cin >> a >> B, when running, separate two input numbers with a space;
Try to practice yourself and enter two numbers at a time.
#include <iostream>
using namespace Std;
int main (int argc, char** argv)
{
int a = 0;
cout << "input A:";
Cin >> A;
cout << "A=" << A;
return 0;
}