Unit 4: Data Types & Operators

Contents Guide

1. C Data Types: Range and Size

Data types in C define the type of data a variable can hold and how much space it occupies in memory.

Data Type Size (typical) Range
char 1 Byte -128 to 127
int 2 or 4 Bytes -32,768 to 32,767 (for 2 bytes)
float 4 Bytes 3.4E-38 to 3.4E+38
double 8 Bytes 1.7E-308 to 1.7E+308

2. Arithmetic & Relational Operators

Arithmetic operators perform mathematical calculations, while relational operators compare values.

Arithmetic Operators

Relational Operators

Used to check the relationship between two operands. Results are always true (1) or false (0).

3. Logical & Conditional Operators

Logical Operators

Used to combine multiple relational expressions.

Conditional (Ternary) Operator

Syntax: condition ? value_if_true : value_if_false;

It is the only operator in C that takes three operands.

4. Bitwise & Assignment Operators

Bitwise Operators

These operators perform operations at the bit level (binary).

Assignment Operators

Used to assign values to variables. C also supports "compound assignment".

5. Unary vs Binary Operators

Operators are categorized by the number of operands they require.

6. Exam Focus Enhancements

Exam Tips
Common Mistakes
Frequently Asked Questions

Q: What is the size of an int in C?
A: It is compiler-dependent, usually 2 bytes on 16-bit systems and 4 bytes on 32/64-bit systems.

Q: Why do we use Bitwise operators?
A: They are used for low-level programming like device drivers or cryptography where direct bit manipulation is needed.