Tuesday, 21 April 2015

Unary Minus Operator Vs Binary Minus

we know minus sign(-) which is used for subtraction(binary minus operator), But what is mean by unary minus operator?

first.. What's the meaning of unary operator?

a unary operation is an operation with only one operand, i.e. a single input


when minus sign is used as unary operator the value of variable is negated.

void main(){
int num = 4;
int negeted_num = -num; //unary operator
printf("Demonstration of Unary Minus Operator\n");
printf("the value of num is %d\n",num);
printf("the value of negeted number \n");
printf("negeted_num = - num --> %d",negeted_num);
getch();
}


and the output is
unary_minus

of all the arithmetic operators unary minus has a highest precedence level

No comments:

Post a Comment