194k views
5 votes
Choose the correct unary operators in C?
1) !
2) -
3) +
4) ++

User Tamon
by
8.0k points

1 Answer

4 votes

Final answer:

The unary operators in C include logical NOT (!), unary minus (-), unary plus (+), and increment (++). These operators act on a single operand to produce a result, such as inverting a boolean value, negating a number, indicating a positive value, or incrementing a value.

Step-by-step explanation:

The correct unary operators in C are !, -, +, and ++. A unary operator is an operator that takes a single operand in an expression or a statement. Examples of unary operators in C include:

  • !: Logical NOT operator. It inverts the boolean value of its operand. For example, if b is true, then !b is false.
  • -: Unary minus. It negates the value of its operand. If x is 5, then -x is -5.
  • +: Unary plus. It indicates the positive value of its operand, often redundant as numbers are positive by default without it.
  • ++: Increment operator, which increases the value of its operand by one. If i is 2, after i++ or ++i, i will be 3.

Therefore, all the options listed are unary operators in C.