In this blog |
---|
unary minus (-) |
increment ( ++) |
decrement (--) |
loagical NOT ( ! )and bitwise NOT ( ~) |
Address of operator (&) and Indirection ( * ) |
sizeof () |
Unary minus (-)
unary minus in c is generally used to invert the sign of the operand for eg , a = -10 so -a will be 10 and keep in mind that the unary minus is different from binary minus
increment ( ++)
.) increment operator is used to increase a particular value by 1 for eg , a = 10 so a++ would be 11 .
.) increment operator is of further of 2 types postfix(a++ )and prefix(++a) increment
.) in an expression when post fix increment is used , like
then first the value of operand is used , in this case it is 1 so expression answer would be 2 and after that the value of operand would be incremented
.) in an expression when prefix increment is used , like
then first the value of operand is incremented then after that expression would be evaluated answer to this expression is 3.
decrement ( -- )
.) decrement operator is used to decrement the value of operand by 1
.)decrement operator is further of 2 type postfix(a--) and prefix(--a) , meaning of these are same as of increment
.) value of the expression (a--) +1 if a is 1 would be 2 and after the expression is evaluated then value of a is decremented
.) value of expression (--a) +1 would be 1.
logical NOT and bitwise NOT
these operator would be discussed late in logical operators.
Address of operator(&) and indirection operator(*)
.) Address of operator when used with variable gives the address of that location , eg when a = 5 the &a would give the address where 5 is stored
.) indirection operator is used with pointer , i know that you would not know about pointer but just remember that when used with pointer it gives the value of the variable which the pointer is pointing at.
sizeof()
.) sizeof operator is used is we want to know the size of a data type or a variable eg ..
sizeof operator always return the value in long unsinged integer so always use %lu format specifier.
No comments:
Post a Comment