C Programming – Detailed Notes
Introduction to C Programming
C is a procedural and structured programming language developed by Dennis Ritchie in 1972. It is
widely used for system programming, embedded systems, and application development.
Features of C
C is fast, efficient, portable, and provides low-level memory access using pointers. It has a rich
library and supports modular programming.
Structure of a C Program
A C program consists of documentation section, preprocessor directives, main function, and
user-defined functions.
Data Types
Basic data types include int, float, char, and double. Derived data types include arrays, pointers,
structures, and unions.
Variables and Constants
Variables are used to store data values, while constants store fixed values.
Operators in C
C supports arithmetic, relational, logical, assignment, increment/decrement, and bitwise operators.
Input and Output Functions
printf() is used for output and scanf() is used for input operations.
Control Statements
Decision-making statements include if, if-else, switch. Looping statements include for, while, and
do-while.
Functions
Functions are blocks of code that perform specific tasks. They help in code reusability and modular
programming.
Arrays
Arrays store multiple values of the same data type in contiguous memory locations.
Strings
Strings are arrays of characters terminated by a null character.
Pointers
Pointers store the address of variables and allow efficient memory management.
Structures and Unions
Structures allow grouping of different data types, while unions share memory among members.
File Handling
File handling allows reading and writing data to files using functions like fopen, fread, fwrite.
Conclusion
C programming is foundational for understanding advanced programming languages and
system-level concepts.