0% found this document useful (0 votes)
6 views12 pages

C++ Conditional and Logical Operators

The document discusses various programming concepts in C++ including if/else statements, logical operators like && and ||, increment/decrement operators like ++ and --, and prefix/postfix forms. It provides examples and explanations of each concept presented by Dr. Md Rakib Hassan from the Department of Computer Science & Mathematics.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views12 pages

C++ Conditional and Logical Operators

The document discusses various programming concepts in C++ including if/else statements, logical operators like && and ||, increment/decrement operators like ++ and --, and prefix/postfix forms. It provides examples and explanations of each concept presented by Dr. Md Rakib Hassan from the Department of Computer Science & Mathematics.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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

You might also like