What is a Unary Operator? Unary Operators are the operators which require only one operand. While binary operator requires two operands and tertiary requires three operands. Unary operators are: +, -, ++, --, sizeof() 1) + and - Note: (+) and (-) are not of addition and subtraction but it denotes only sign of operator as positive or negative. Ex. +1, +2, +3... -1, -2, -3... 2) ++ and -- It seems to be ++ (two plus-plus), But it is a single operator. It is called the increment operator . Increment operator are of two type: i) Pre increment ii) Post increment The meaning of both the increments is the same. i.e To add +1 in any value x++ or ++x; or to increase the value by 1. x++ is x=x+1 where x is a variable. Example: 7++ output is 8 25++ output is 26 program: (Pre-increment) #include <stdio.h> #include <conio.h> int main() { int x=7; ++x; / /Whe...
Comments
Post a Comment