Unit III: Constants, Variables and Data Types

Table of Contents

1. Character Set and C Tokens

The Character Set includes all characters that the C compiler can recognize, such as letters (A-Z, a-z), digits (0-9), and special characters.

C Tokens are the smallest individual units in a program. These include:


2. Keywords and Identifiers

Keywords are reserved words that have a special meaning to the compiler and cannot be used as variable names (e.g., int, float, if).

Identifiers are names used for variables, functions, and arrays.


3. Constants and Variables

Constants are values that remain unchanged during program execution. These can be numeric (integer, real) or character constants.

Variables are identifiers used to store data values that can change during execution.


4. Data Types and Declarations

Data Types specify the type of value a variable can store.


5. Operators and Expressions

Operators are symbols that trigger an action when applied to variables and constants.

Operator Category Operators Description
Arithmetic +, -, *, /, % Perform basic math like addition and modulus.
Relational <, >, <=, >=, ==, != Compare two values for true/false results.
Logical &&, ||, ! Combine multiple conditions.
Assignment = Store a value in a variable.
Increment/Decrement ++, -- Increase or decrease a value by 1.
Conditional ? : A shorthand for simple if-else statements.

Arithmetic Expressions are combinations of variables, constants, and operators evaluated according to rules of precedence.

Exam Tips


Frequently Asked Questions

Q1: What is a keyword?
A keyword is a word reserved by the C language for specific purposes (like int for integers) and cannot be used as a name for variables.

Q2: What is the difference between a constant and a variable?
A constant's value is fixed and cannot be changed during the program, whereas a variable acts as a container whose content can be modified.