Relational and Logical

Relational Operators: ==, <, >, <=, >=, !=

Operators Relative Precedence
< <= > >= 1
!= == 2

Logical operators: &&, ||, !

Expression What It Evaluates To
(exp1 && exp2) True (1) only if both exp1 and exp2 are true; false (0) otherwise
(exp1 || exp2) True (1) if either exp1 or exp2 is true; false (0) only if both are false
(!exp1) False (0) if exp1 is true; true (1) if exp1 is false

Truth Table

Op1 Op2 && (And) || (Or) ! (Not) ^ (XOR)
TRUE TRUE TRUE TRUE FALSE FALSE
FALSE TRUE FALSE TRUE TRUE TRUE
TRUE FALSE FALSE TRUE FALSE TRUE
FALSE FALSE FALSE FALSE TRUE FALSE

Compound Assignment Operators:
C compound assignment operators provide a shorthand method for combining a binary mathematical operation
with an assignment operation
Assignment Operators: +=, -=, *=, /=, %=, <<=, >>=, &=, |=, ^=.

Ex. x = x + 5;

Using a compound assignment operator, which you can think of as a shorthand method of assignment, you would
write
x += 5;

null

Mr. Sandeep Soni

Founder, Trainer & CEO, Deccansoft Software Services.

Sandeep has 21 yrs of experience working in various Microsoft Technologies/Platforms incl. VB6.0, ASP, VC++, VB.NET, C#. He is involved in managing and architecting projects at Deccansoft. He will be your liaison to Deccansoft, for any kind of communication and project updates. He knows what works and what doesn’t, and what practices are most suitable for design and programming with the ultimate goal of producing a quality system.