Operator and Statements

Operator is a symbol commonly involved in the program for perform an operation or manipulation, for example to:
- add two values
- assign value to a variable (assignment)
- comparing the similarity of two values​​.
a. Arithmetic Operator
This operator is used for basic arithmetic calculations. These operators include:
- Multiplication (*)
- Distribution (/) - Divide
- Addition (+)
- Reduction (-)
- Modulus (%)
b. Relational Operator 
This operator is used to compare two values​​. Here's many operator of this type.
- Equal (==)
- Not equal (!=)
- Smaller (<)
- Bigger (>)
The result of this operator is true or false statements. Look this sample program:
value_1 = 3 > 2;
value_2 = 15 == 16;
cout << “Result of value 1 = ”<< value_1 << “\n”;
cout << “Result of value 2 = ”<< value_2 << “\n”;
c. Logical Operator
This operator is used to connect 2 or more statements. Usually statement is linked is a relational operation. Logical operators as well logic value true or false.
- AND (&&)
- OR (||)
- NOT (!)


Look this sample program.
number1 = (3 > 2) && (4 < 10);
number2 = !(15 == 15);
cout << “Result of number1 = ”<< number1 << “\n”;
cout << “Result of number2 = ”<< number2 << “\n”;

0 comments



Recent Entries