Module 1: Introduction to C Language -
Comprehensive Exam Guide
History of C Language
C was developed by Dennis Ritchie in 1972 at Bell Labs. It evolved from B language and was used
to develop UNIX. C is called a middle-level language because it combines hardware-level control
with high-level programming features. Advantages include speed, portability, modularity, and
efficiency.
Structure of a C Program
A C program consists of documentation section, header files, global declarations, main function,
variable declarations, executable statements, and return statement. Execution always starts from
main().
Character Set
The character set includes alphabets, digits, special symbols, and white spaces. These characters
are used to form tokens and statements.
Tokens
Tokens are the smallest meaningful units of a C program. Types: keywords, identifiers, constants,
strings, operators, and special symbols. Example: int age = 18; contains multiple tokens.
Keywords
Keywords are reserved words with predefined meanings. Examples: int, float, char, if, else, while,
for, return, break, continue. Keywords cannot be used as identifiers.
Identifiers
Identifiers are names given to variables, functions, arrays, etc. Rules: must begin with a letter or
underscore, cannot contain spaces, and cannot be a keyword.
Constants
Constants are fixed values that do not change during program execution. Types include integer
constants, floating-point constants, character constants, and string constants.
Variables
Variables are memory locations used to store data. Declaration allocates memory, while
initialization assigns an initial value.
Data Types
Basic data types: int, char, float, double. Derived types include arrays and pointers. User-defined
types include structures, unions, and enumerations.
Operators
Operators perform operations on operands. Categories include arithmetic, relational, logical,
assignment, bitwise, increment/decrement, conditional, and special operators.
Arithmetic Operators
Addition (+), subtraction (-), multiplication (*), division (/), and modulus (%) are used for
mathematical calculations.
Relational and Logical Operators
Relational operators compare values. Logical operators combine conditions and are widely used in
decision making.
Bitwise Operators
Bitwise operators work directly on binary representations of data. They are useful in embedded and
system programming.
Operator Precedence
Operator precedence determines the order in which operators are evaluated. Parentheses have the
highest precedence and assignment operators have lower precedence.
Type Conversion
Implicit conversion occurs automatically. Explicit conversion uses type casting. Example: (float)10/3
produces a floating-point result.
Mathematical Functions
The math.h header provides functions such as sqrt(), pow(), ceil(), floor(), and fabs().
Input Functions
scanf() reads data from the keyboard. getchar() reads a single character.
Output Functions
printf() displays formatted output. putchar() prints a single character.
Format Specifiers
Important format specifiers: %d for int, %f for float, %c for char, %s for string, and %lf for double.
Sample Program: Addition
Algorithm: Read two numbers, add them, display the result. This is one of the most frequently
asked beginner programs.
Sample Program: Area of Circle
Formula: Area = πr². Read radius from user and compute area using floating-point variables.
Sample Program: Simple Interest
Formula: SI = (P × R × T) / 100. Demonstrates arithmetic expressions.
Exam Preparation Tips
Study definitions exactly. Learn all operators with examples. Practice scanf and printf. Memorize
important format specifiers and sample programs.
History of C Language
C was developed by Dennis Ritchie in 1972 at Bell Labs. It evolved from B language and was used
to develop UNIX. C is called a middle-level language because it combines hardware-level control
with high-level programming features. Advantages include speed, portability, modularity, and
efficiency.
Structure of a C Program
A C program consists of documentation section, header files, global declarations, main function,
variable declarations, executable statements, and return statement. Execution always starts from
main().
Character Set
The character set includes alphabets, digits, special symbols, and white spaces. These characters
are used to form tokens and statements.
Tokens
Tokens are the smallest meaningful units of a C program. Types: keywords, identifiers, constants,
strings, operators, and special symbols. Example: int age = 18; contains multiple tokens.
Keywords
Keywords are reserved words with predefined meanings. Examples: int, float, char, if, else, while,
for, return, break, continue. Keywords cannot be used as identifiers.
Identifiers
Identifiers are names given to variables, functions, arrays, etc. Rules: must begin with a letter or
underscore, cannot contain spaces, and cannot be a keyword.
Constants
Constants are fixed values that do not change during program execution. Types include integer
constants, floating-point constants, character constants, and string constants.
Variables
Variables are memory locations used to store data. Declaration allocates memory, while
initialization assigns an initial value.
Data Types
Basic data types: int, char, float, double. Derived types include arrays and pointers. User-defined
types include structures, unions, and enumerations.
Operators
Operators perform operations on operands. Categories include arithmetic, relational, logical,
assignment, bitwise, increment/decrement, conditional, and special operators.
Arithmetic Operators
Addition (+), subtraction (-), multiplication (*), division (/), and modulus (%) are used for
mathematical calculations.
Relational and Logical Operators
Relational operators compare values. Logical operators combine conditions and are widely used in
decision making.
Bitwise Operators
Bitwise operators work directly on binary representations of data. They are useful in embedded and
system programming.
Operator Precedence
Operator precedence determines the order in which operators are evaluated. Parentheses have the
highest precedence and assignment operators have lower precedence.
Type Conversion
Implicit conversion occurs automatically. Explicit conversion uses type casting. Example: (float)10/3
produces a floating-point result.
Mathematical Functions
The math.h header provides functions such as sqrt(), pow(), ceil(), floor(), and fabs().
Input Functions
scanf() reads data from the keyboard. getchar() reads a single character.
Output Functions
printf() displays formatted output. putchar() prints a single character.
Format Specifiers
Important format specifiers: %d for int, %f for float, %c for char, %s for string, and %lf for double.
Sample Program: Addition
Algorithm: Read two numbers, add them, display the result. This is one of the most frequently
asked beginner programs.
Sample Program: Area of Circle
Formula: Area = πr². Read radius from user and compute area using floating-point variables.
Sample Program: Simple Interest
Formula: SI = (P × R × T) / 100. Demonstrates arithmetic expressions.
Exam Preparation Tips
Study definitions exactly. Learn all operators with examples. Practice scanf and printf. Memorize
important format specifiers and sample programs.
History of C Language
C was developed by Dennis Ritchie in 1972 at Bell Labs. It evolved from B language and was used
to develop UNIX. C is called a middle-level language because it combines hardware-level control
with high-level programming features. Advantages include speed, portability, modularity, and
efficiency.
Structure of a C Program
A C program consists of documentation section, header files, global declarations, main function,
variable declarations, executable statements, and return statement. Execution always starts from
main().
Character Set
The character set includes alphabets, digits, special symbols, and white spaces. These characters
are used to form tokens and statements.
Tokens
Tokens are the smallest meaningful units of a C program. Types: keywords, identifiers, constants,
strings, operators, and special symbols. Example: int age = 18; contains multiple tokens.
Keywords
Keywords are reserved words with predefined meanings. Examples: int, float, char, if, else, while,
for, return, break, continue. Keywords cannot be used as identifiers.
Identifiers
Identifiers are names given to variables, functions, arrays, etc. Rules: must begin with a letter or
underscore, cannot contain spaces, and cannot be a keyword.
Constants
Constants are fixed values that do not change during program execution. Types include integer
constants, floating-point constants, character constants, and string constants.
Variables
Variables are memory locations used to store data. Declaration allocates memory, while
initialization assigns an initial value.
Data Types
Basic data types: int, char, float, double. Derived types include arrays and pointers. User-defined
types include structures, unions, and enumerations.
Operators
Operators perform operations on operands. Categories include arithmetic, relational, logical,
assignment, bitwise, increment/decrement, conditional, and special operators.
Arithmetic Operators
Addition (+), subtraction (-), multiplication (*), division (/), and modulus (%) are used for
mathematical calculations.
Relational and Logical Operators
Relational operators compare values. Logical operators combine conditions and are widely used in
decision making.
Bitwise Operators
Bitwise operators work directly on binary representations of data. They are useful in embedded and
system programming.
Operator Precedence
Operator precedence determines the order in which operators are evaluated. Parentheses have the
highest precedence and assignment operators have lower precedence.
Type Conversion
Implicit conversion occurs automatically. Explicit conversion uses type casting. Example: (float)10/3
produces a floating-point result.
Mathematical Functions
The math.h header provides functions such as sqrt(), pow(), ceil(), floor(), and fabs().
Input Functions
scanf() reads data from the keyboard. getchar() reads a single character.
Output Functions
printf() displays formatted output. putchar() prints a single character.
Format Specifiers
Important format specifiers: %d for int, %f for float, %c for char, %s for string, and %lf for double.
Sample Program: Addition
Algorithm: Read two numbers, add them, display the result. This is one of the most frequently
asked beginner programs.
Sample Program: Area of Circle
Formula: Area = πr². Read radius from user and compute area using floating-point variables.
Sample Program: Simple Interest
Formula: SI = (P × R × T) / 100. Demonstrates arithmetic expressions.
Exam Preparation Tips
Study definitions exactly. Learn all operators with examples. Practice scanf and printf. Memorize
important format specifiers and sample programs.
Important 2-Mark Questions
• What is C language?
• Define token.
• What is an identifier?
• What is a variable?
• What is type conversion?
• List arithmetic operators.
• What is a keyword?
Important 5-Mark and 10-Mark Questions
• Explain the structure of a C program.
• Explain tokens with examples.
• Describe data types and variables.
• Explain all operators in C with examples.
• Explain input and output functions with examples.