---
title: "Unary operators in C"
subject: "Computer Programming"
chapter: 3
key: "semester_1/computer_programming:unary-operators"
source: https://www.bctengineer.com/q/semester_1/computer_programming/unary-operators
site: BCT Engineering
---

# Unary operators in C

Computer Programming · Chapter 3: Introduction to ‘C’ programming

- Asked in: 2068 Chaitra, 2 marks
- Video: [C_13 Operators in C - Part 1 | Unary , Binary and Ternary Operators in C | C programming Tutorials](https://www.youtube.com/watch?v=E1_Gg6dURwk) — Jenny's Lectures CS IT
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_1/computer_programming/unary-operators
- Whole chapter: https://www.bctengineer.com/md/semester_1/computer_programming/chapter-3

## Question

What are unary operators in C? Why are they named so?

## Short answer

Unary operators operate on a single operand. They include unary +/-, ++, --, !, ~, &, *, sizeof, and type cast. The term unary means 'one' because they require only one operand, unlike binary operators.

## Answer

**Unary operators** are operators that work on a single operand. They are called "unary" because *uni* means one: they need only one operand, unlike binary operators (`a + b`) which need two.

| Operator | Meaning | Example |
|---|---|---|
| `+` , `-` | unary plus / minus | `-a` |
| `++` , `--` | increment / decrement | `++a`, `a--` |
| `!` | logical NOT | `!a` |
| `~` | bitwise complement | `~a` |
| `&` | address of | `&a` |
| `*` | value at address (pointer) | `*p` |
| `sizeof` | size in bytes | `sizeof(a)` |
| `(type)` | type cast | `(float)a` |

```c
#include <stdio.h>
int main(void)
{
    int a = 5, b;
    b = -a;
    printf("%d %d\n", b, +a);
    printf("%d\n", !a);
    printf("%d\n", ++a);
    printf("%d\n", a--);
    printf("%d %d\n", a, (int)sizeof(a));
    return 0;
}
```
Output:
```text
-5 5
0
6
6
5 4
```

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Why are they called unary operators?
   A. They work on one operand
   B. They work on two operands
   C. They have one symbol
   D. They return one
   Answer: A. Uni means one: they need only a single operand. (Key point: Why unary)

2. Which of these is NOT a unary operator?
   A. !
   B. sizeof
   C. ++
   D. + in a + b
   Answer: D. In a + b the + is binary; it is unary only as in +a. (Key point: Which unary)

3. If a = 5, what do ++a and then a-- print in the example?
   A. 6 then 6
   B. 5 then 6
   C. 6 then 5
   D. 5 then 5
   Answer: A. ++a makes a 6 and prints 6; a-- prints the old value 6, and a becomes 5. (Key point: Pre vs post)

## Related in other subjects

- [NO₂ and SO₂ sources; role in acid rain](https://www.bctengineer.com/question.md?key=semester_2%2Fengineering_chemistry%3Ano2-so2-acid-rain) — Engineering Chemistry, chapter 3
- [Acid rain; sources and control of CO and SO₂](https://www.bctengineer.com/question.md?key=semester_2%2Fengineering_chemistry%3Aacid-rain-co-so2) — Engineering Chemistry, chapter 3
- [Transition elements; why so called; 3d configurations](https://www.bctengineer.com/question.md?key=semester_2%2Fengineering_chemistry%3Atm-called-config) — Engineering Chemistry, chapter 5
