C Programming - Expressions - Discussion

Discussion Forum : Expressions - General Questions (Q.No. 5)
5.
Which of the following are unary operators in C?
1. !
2. sizeof
3. ~
4. &&
1, 2
1, 3
2, 4
1, 2, 3
Answer: Option
Explanation:

An operation with only one operand is called unary operation.
Unary operators:
! Logical NOT operator.
~ bitwise NOT operator.
sizeof Size-of operator.

&& Logical AND is a logical operator.

Therefore, 1, 2, 3 are unary operators.

Discussion:
10 comments Page 1 of 1.

Vaqash Khan said:   2 years ago
Sizeof (arg) it is a function or operator.

In order to be a function.

Arg - for which we want to calculate the size like sizeof (int), sizeof (float), etc.
Function name: sizeof ():The function name ends with open and close parenthesis.
Return value: sizeof () function returns the value as computing the size of the data type.

Ansh said:   3 years ago
Airthematic Operator hierarchy in C Language is different from BODMAS.
In C, multiplication comes before division.
i.e;

* /% +-=.

Amoakok said:   6 years ago
Thanks all for explaining.

Pallab Patra said:   8 years ago
We have following Unary Operators in C :

! (logical negation),
~ (one\'s complement or bitwise negation),
" (unary minus),
+ (unary plus),
& (addressof),
* (dereferencing),
++ (pre-increment),
- -(pre-decrement),
sizeof() operator,
(type) or cast operator.
(1)

Nagesh Bandari said:   1 decade ago
"++x" means "x" value will be changed before execution.

Assume x=1;

printf("++x",x);

++x operation changes the "x" value to "2".

Here O/P: 2.

x++ means "x" value will be changed after execution.

Assume x=5;

printf("x++",x);

O/P: 5 only.

But now "x" value is "6".

Jasna said:   1 decade ago
What is the difference between ++x; and x++;?

Venkat said:   1 decade ago
++ and -- are increment operators. What is difference?

Harsh said:   1 decade ago
The unary operator are ~, ++, --, sizeof, !

Akshay said:   1 decade ago
@Virendra: Unary operators are those who do not refer values at the left of the operation. e.g.!1 will return 0 you need not compare or evaluate two values. See Unary and Binary operator overloading to understand the concept more.

Virendra said:   1 decade ago
Are you mean that Logical NOT operator is not logical operator?

Post your comments here:

Your comments will be displayed after verification.