If statement
If statements are also called judgment statements, such as whether it is correct, larger than the size, and so on, let's 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 "if" as the filename, save the file to its own folder;
2, input program code
1 first to see a judge of the traffic lights, enter a number, 1 for light, 0 for the kill, red stop, Green Line;
2 in the Blue Code area below, enter the following code (press TAB to jump lattice,//followed by comments, you can not enter);
int: 0;
cout << "Input: (0|1)";
CIN >>;
if (+ = 1)
{
cout << "ting";//press the TAB key
}
else//Click Backspace key
{
cout << "Xing";
}
3 The first paragraph is to define the variable and give the initial value,
The second paragraph is the hint and enter a number for the variable,
4 The third paragraph is divided into two if and else, is two choose one, choose which one according to the conditions in parentheses,
If the value is 1, run cout << "Ting", otherwise run the following line "cout << Xing"