Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

The GNU C Programming Tutorial - Logical operators

Node:Logical operators, Next:, Previous:Comparisons and logic, Up:Expressions and operators



Logical operators

Comparisons are often made in pairs or groups. For example, you might want to ask a question such as, "Is variable a greater than variable b and is variable b greater than variable c?" The word "and" in the question above is represented in C by the logical operator (an "operator on Boolean values") &&, and the whole comparison above might be represented by the following expression:

(a > b) && (b > c)

The main logical operators in C are as follows:

&&
logical AND
||
logical Inclusive OR (See Inclusive OR.)
!
logical NOT

Here is another example. The question, "Is the variable a greater than the variable b, or is the variable a not greater than the variable c?" might be written:

(a > b) || !(a > c)

 
 
  Published under free license. Design by Interspire