Logical Operators

Logical Operators

&&, ||, !

Logical operators are used to perform logical operations.

It always return true or false.


&&

It is called logical AND.

true && true returns true
true && false returns false
false && true returns false
false && false returns false

example:
m = 10;
n = 20;
p = 30;
q = 40;
res = (a < b) && (p > q);
In this example a < b returns true and p > q returns false therefore res will be false


||

It is called logical OR.

true || true returns true
true || false returns true
false || true returns false
false || false returns false

example:
m = 10;
n = 20;
p = 30;
q = 40;
res = (a < b) || (p > q);
In this example a < b returns true and p > q returns false therefore res will be true


!

It is called logical OR.

example:
!(10 < 20) returns false
!(10 > 20) returns true


See Output

About Us

Comsysapp.com is an educational website. Students and software developers can learn programming language tutorials. Comsysapp is very useful for beginners and professional developers. Comsysapp provides tutorial in easy language. Comsysapp.com has focus on simplicity.

Services

Comsysapp.com provides free tutorials like c, html, css, etc. All tutorials are free for beginner and professionals.


Terms of Use

comsysapp.com is not responsible for any mistake. We are not responsible if information made available on our website is incomplete or invalid. But comsysapp.com always try for zero-zero mistake.

Privacy policy

comsysapp.com does not collect any data from users. We use Google AdSense advertising on our website. We never ask personal or private information.


Sitemap

sitemap

copyright © 2023