C Notes
C Notes
by Rahat Naz,
Assistant Professor
1. Introduction to C Programming
History of C
Features of C
1) Procedural language
2) Portability and flexibility
3) Rich library functions
4) Efficient memory management
Structure of a C Program
5) Documentation Section
6) Link Section
7) Definition Section
8) Global Declaration Section
9) Main Function Section
10) Subprogram Section
First Program in C
11) Writing a simple C program
12) Compiling and running the program
2. Basics of C Programming
Tokens in C
1) Keywords
2) Identifiers
3) Constants
4) Variables
5) Data types
Operators in C
6) Arithmetic operators
7) Relational operators
8) Logical operators
9) Bitwise operators
10) Assignment operators
11) Miscellaneous operators
Expressions and Statements
12) Expression types
13) Evaluating expressions
14) Writing statements in C
3. Control Structures
1) Conditional Statements
1) if, if-else, nested if-else
2) switch statement
2) Looping Statements
1) for loop
2) while loop
3) do-while loop
4) Nested loops
3) Jump Statements
1) break
2) continue
3) goto
4) exit()
1) 4. Functions
4) Introduction to Functions
1) Function definition
2) Function declaration
3) Function calling
5) Types of Functions
1) User-defined functions
2) Library functions
6) Parameter Passing
1) Call by value
2) Call by reference
7) Recursion
1) Understanding recursion
2) Examples of recursive functions
1) 5. Arrays and Strings
8) Introduction to Arrays
1) Declaration and initialization
2) One-dimensional arrays
3) Two-dimensional arrays
4) Multidimensional arrays
9) Operations on Arrays
1) Insertion
2) Deletion
3) Searching
4) Sorting
10) Introduction to Strings
1) Declaration and initialization of strings
2) String handling functions (strlen, strcat, strcpy, strcmp)
3) String manipulation
1) 6. Pointers
11) Introduction to Pointers
1) Pointer basics
2) Pointer arithmetic
3) Pointer to pointer
12) Pointers and Arrays
1) Pointer to an array
2) Array of pointers
13) Pointers and Functions
1) Passing pointers to functions
2) Returning pointers from functions
14) Dynamic Memory Allocation
1) malloc(), calloc(), realloc(), free()
1) 7. Structures and Unions
15) Introduction to Structures
1) Defining a structure
2) Accessing structure members
3) Array of structures
4) Nested structures
5) Pointer to structure
16) Unions
1) Defining and using unions
2) Difference between structure and union
1) 8. File Handling in C
17) Introduction to File Handling
1) File types (Text and Binary)
2) File operations (open, close, read, write)
18) File I/O Functions
1) fopen(), fclose(), fprintf(), fscanf(), fputc(), fgetc(), fread(), fwrite()
19) Working with Files
1) Reading and writing files
2) Appending to a file
3) Random access to files using fseek(), ftell(), rewind()
1) 9. Advanced Topics
20) Preprocessor Directives
1) #define, #include, #ifdef, #endif
2) Macro substitution
21) Bitwise Operators
1) Bitwise AND, OR, XOR
2) Bitwise shift operators
22) Command Line Arguments
1) Understanding command-line arguments
2) Using argc and argv
23) Memory Management
1) Dynamic memory allocation
2) Memory leak and its prevention
1) 10. Practice Problems and Examples
24) Basic Programs
1) Hello World
2) Sum of two numbers
3) Swapping two numbers
25) Control Structures
1) Largest of three numbers
2) Fibonacci series
3) Prime number checking
26) Functions and Recursion
1) Factorial of a number
2) GCD of two numbers
3) Tower of Hanoi
27) Arrays and Strings
1) Linear search
2) Bubble sort
3) String palindrome checking
28) Pointers and Structures
1) Pointer-based array operations
2) Student record system using structures
29) File Handling
1) Read and write student records to a file
2) Simple file encryption and decryption
Introduction to C Programming
What is C?
C is a general-purpose, high-level programming language that was developed by Dennis Ritchie at
Bell Labs in 1972. It is one of the oldest and most widely used programming languages and serves
as the foundation for many modern programming languages like C++, Java, and Python.
Features of C:
1) Simplicity: C has a simple syntax and provides low-level access to memory, making
it efficient.
2) Portability: C code can be compiled on various platforms with minimal
modifications, making it highly portable.
3) Structured Language: C allows for the use of functions, loops, and conditionals,
promoting structured programming.
4) Rich Library: C comes with a standard library that offers numerous built-in
functions for handling tasks like input/output, string manipulation, and more.
5) Fast Execution: C is known for its speed and is often used in system-level
programming where performance is critical.
Why Should Computer Science Engineers Study C?
Foundation for Understanding Programming Concepts:
1) Learning C helps students understand fundamental programming concepts such as
data types, control structures, arrays, pointers, memory management, and functions.
These concepts are crucial for understanding more advanced languages and
technologies.
System-Level Programming:
2) C is widely used in developing operating systems, embedded systems, and other low-
level applications. Understanding C enables students to work on system-level
programming and hardware-related tasks.
Efficiency and Performance:
3) C is known for its performance and efficiency, making it ideal for applications where
resource constraints are critical. This includes real-time systems, games, and high-
performance computing.
Understanding Computer Architecture:
4) By working with C, students get a better understanding of how computers operate,
especially regarding memory management, CPU architecture, and the relationship
between software and hardware.
Gateway to Other Programming Languages:
5) C serves as a stepping stone to learning other programming languages. Once students
master C, they find it easier to learn languages like C++, Java, and Python, as these
languages share similar syntax and concepts.
Industry Demand:
6) Many companies still use C for legacy systems and performance-critical applications.
Having knowledge of C makes students more versatile and increases their
employability.
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}