Second, variable
program processing of data, generally through the external keyboard input, first to put into the memory of the different units, this is the variable, let's look at a practice;
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 "Bianliang" as the filename, save the file to its own folder;
2, input program code
1 in the Blue Code area below, enter a line int A;
#include <iostream>
using namespace Std;
int main (int argc, char** argv)
{
int A;
return 0;
}
2 This line defines a variable a, and the preceding int represents an integer variable that holds integers, char, and only one letter,
This is the equivalent of having a cup of water, small or large, to buy as needed;
2. Assigning values to variables
1) Then click the ENTER key to the next line, enter a = 20;
int A;
A = 20;
3 This line is to assign a value to the variable a, the value can be more than the maximum size according to the type of variable to decide,
The equivalent of pouring water into a cup, fill a cup at most, and more will overflow;
4) to the next line, enter cout << A; Show the value of a, the equivalent of a cup to take a look at;
int A;
A = 20;
cout << A;
Save, compile, build, run, and see the results of the display;
5 Return to continue to enter the following content, to assign the variable value, the equivalent of a glass of water poured;
int A;
A = 20;
cout << a << Endl;
A = 6;
cout << A;
6 save, compile, build, run, at this time a store is 6;
7 in general, the variable is like a box, which can be loaded, can be reused, but after the contents will cover the front;
Definitions and assignments can be performed together, for example int a = 20; is also very good;
#include <iostream>
using namespace Std;
int main (int argc, char** argv)
{
int A;
A = 20;
cout << a << Endl;
A = 6;
cout << A;
return 0;
}