Iii. Input statements
We have learned the output statement cout. in this section, we will learn the input statement cin (read as c-in). Let's take a look at this exercise;
1. Start Geany
1) Click "Application-programming-Geany" in the menu to start Geany and create a c ++ source program;
2) Click the "file-save as" command to save the file to your folder with "shuru" as the file name;
2. Enter the program code.
1) in the following blue code area, enter the following statement:
Int a = 0;
Cout <"input :";
Cin>;
Cout <"a =" <;
2) The first line defines an integer variable a with a value of 0,
The second line displays a prompt. The third line executes the input statement (read as c-in), and the fourth line displays the content in variable;
3) after saving, compiling, generating, and running, a prompt is displayed first. The cursor is flashing and a number is required;
4) press the keyboard, enter 20, and then press the Enter key to display that the value of variable a is 20;
5) You can also enter multiple numbers in the cin statement, for example, cin> a> B. separate the two numbers with spaces during running;
Try to exercise and enter two numbers at the same time;
# Include <iostream>
Using namespace std;
Int main (int argc, char ** argv)
{
Int a = 0;
Cout <"input :";
Cin>;
Cout <"a =" <;
Return 0;
}