
















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A comprehensive overview of operators in c programming, covering various types like arithmetic, relational, logical, bitwise, and assignment operators. It explains their functionality, precedence, and associativity with clear examples. The document also includes a quiz section to test understanding and a faq section addressing common questions about operators in c.
Typology: Lecture notes
1 / 24
This page cannot be seen from the preview
Don't miss anything!
OPERATION OPERATOR SYNTAX COMMENT RESULT Multiply * a * b result = a * b 27 Divide / a / b result = a / b 3 Addition + a + b result = a + b 12 Subtraction - a - b result = a – b 6 Modulus % a % b result = a % b 0 For a=9, b=
OPERATOR MEANING EXAMPLE && LOGICAL AND (6>5) && (7>9) GIVES 0 || LOGICAL OR (6>5) || (7>9) GIVES 1 ! LOGICAL NOT !(6>5) GIVES 0
OPERATOR MEANING EXAMPLE & BITWISE AND 5 & 6 GIVES 4 0101 & 0110 = 0100 | BITWISE OR 5 | 6 GIVES 7 ^ BITWISE X-OR 5 ^ 6 GIVES 3 << BITWISE LEFT SHIFT 5<<2 GIVES 20
BITWISE RIGHT SHIFT 5>>2 GIVES 1 ~ BITWISE NOT ~6 GIVES -
OPERATOR MEANING EXAMPLE ++ INCREMENT A++ INCREMENTS THE VALUE OF A TO 1 -- DECREMENT A– DECREMENTS THE VALUE OF A TO 1
OPERATOR MEANING EXAMPLE ? : TERNARY OPERATOR A>B?A:B
Operator Description Associativity Precedence Level +
- Addition operator Subtraction operator Left-to-right 4 >> << Right shift operator Left shift operator Left-to-right 5 **< <=
=** Less than Less than or equal operator Greater than
Greater than or equal to Left-to-right 6 == != Equal to Not equal to Left-to-right 7 & Bitwise AND (^) Left-to-right 8 ^ Bitwise XOR (^) Left-to-right 9 | Bitwise OR (^) Left-to-right 10 && Logical AND (^) Left-to-right 11 || Logical OR (^) Left-to-right 12
= /= %= += -= &= ^= |= <<= >>=* Assignment operator Right-to-Left 14 , Comma operator^ Left-to-right^15