IF…ELSE,
LOGICAL OPERATORS,
++/--OPERATORS
Dr. Md Rakib Hassan
Associate Professor,
Dept. of Computer Science & Mathematics.
If
2
if (condition)
{
// if the condition is true
}
Dr. Md. Rakib Hassan
If… Else
3
if (condition)
{
// if condition is true
}
else
{
// if condition is false
}
Dr. Md. Rakib Hassan
If … Else if … Else
4
if (condition1)
{
// if condition1 is true
}
else if (condition2)
{
// if condition2 is true
}
….
else
{
// if all the above conditions are false
}
Dr. Md. Rakib Hassan
Logical Operators in C++
5
&&
Logical AND
II
Logical OR
Dr. Md. Rakib Hassan
Logical AND (&&)
6
a b a && b
false false false
false true false
true false false
true true true
Dr. Md. Rakib Hassan
Logical OR (II)
7
a b a || b
false false false
false true true
true false true
true true true
Dr. Md. Rakib Hassan
Operators in C++
8
a = a + b;
a += b;
b = b – c;
b -= c;
y = y * z;
y *= z;
Dr. Md. Rakib Hassan
Increment/ Decrement
9
x++;
x = x + 1;
x--;
X = x – 1;
Dr. Md. Rakib Hassan
Prefix/ Postfix Forms
10
Prefix:
++x;
--x;
Increment or decrement will be done before rest of the
expression
Postfix:
x++;
x--;
Increment or decrement will be done after the
complete expression is evaluated.
Dr. Md. Rakib Hassan
Questions???
11 Dr. Md. Rakib Hassan
Course Lectures
12
[Link]/cpp
Dr. Md. Rakib Hassan