+ 7
What are the unary operators in c?
What are the unary operators in c? ^& = ++ ~
3 Antworten
+ 3
Those operator work with single operand know as unary operator
=
-
++
---
+ 7
Unary operators are operators that act upon a single operand instead of multiple.
For example:
int x = 5;
int y = -x;
Variable y would be -5 because your adding the negative sign to x.
Another example are increments.
1.
int a = 1;
int b = a + 1;
----------------------
2.
int a = 1;
int b = ++a;
Variable b would be 2 because you're incrementing it by one. This is different from #1 because #1 is using 2 operands (a and 1) while #1 is using 1 (a)
+ 3
1. x++
Here (++) is an unary operator
because it's have only one operand (x).
2.x+y
Here (+) is a binary operator because it's have two operand (x and y).