C Programming – Short Notes
Introduction to C
● C is a general-purpose, procedural programming language developed by Dennis Ritchie.
● Widely used for system programming and embedded systems.
Basic Structure of C Program
● Documentation section
● Link section
● Definition section
● Global declaration section
● main() function
● User-defined functions
Data Types
● Primary: int, char, float, double
● Derived: array, pointer, structure, union
● User-defined: enum, typedef
Operators
● Arithmetic: +, -, *, /, %
● Relational: <, >, <=, >=, ==, !=
● Logical: &&, ||, !
● Assignment: =, +=, -=
Control Statements
● Decision making: if, if-else, switch
● Looping: for, while, do-while
● Jumping: break, continue, goto
Functions
● Block of code performing a specific task
● Types: Library functions and User-defined functions
● Function call by value and call by reference
Arrays
● Collection of similar data elements
● Types: 1D array, 2D array
Pointers
● Stores address of another variable
● Used for dynamic memory, arrays, functions
Structures and Unions
● Structure: collection of different data types
● Union: shares memory among members
File Handling
● Used to store data permanently
● Functions: fopen(), fclose(), fprintf(), fscanf()