'IF' is a word which makes most of the world. It's also in C++.
If (expression) ProgramStatement;
Note: There is no semicolon after the brackets.
The compiler evaluates the expression and if it's value is true ProgramStatment is executed, otherwise ProgramStatment is ignored.
If (expression) ProgramStatement1; Else ProgramStatement2;
The compiler evaluates expression and if it's value is true ProgramStatement1 is executed, otherwise ProgramStatement2 is executed.
#pragma hdrstop #include <iostream.h> #include <conio.h> int main() { int Age; cout << "Please enter your age: "; cin >> Age; if(Age <= 21) cout << "You are young."; else cout << "You are old."; getch(); }This code asks the user how old thay are, then insults them depending on there answer.
The code includes a "relational operator".
< is less than
> is greater/more than
>= is greater than or equal to
<= is less than or equal to
== is equal to
!= is not equal to
If the users answer is under 21 the program says "You are young", else is says "You are old".