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
of all the arithmetic operators unary minus has a highest precedence level
No comments:
Post a Comment