Programming core
Programming Fundamentals
5 self-contained study topics — notes, diagrams, formulas, and worked examples for exams and GATE.
Topics
- Variables and Data TypesA variable is a named, typed storage location; the type fixes how many bytes are used, how the bit pattern is interpreted, and the range of values it can hold, which is why signed n-bit integers span −2^(n−1) to 2^(n−1)−1.
- Control StructuresControl structures decide the order of execution: selection (if/switch) chooses among paths and iteration (for/while) repeats a block, with break and continue giving fine control over loop flow.
- Functions and Modular ProgrammingFunctions package reusable logic behind a signature; each call pushes a stack frame holding parameters and the return address, so recursion depth is bounded by stack size and argument-passing mode (value versus reference) decides whether the caller’s data can change.
- Pointers and Memory BasicsA pointer stores a memory address; dereferencing it reaches the value there, pointer arithmetic scales by the pointed-to type’s size, and dynamic memory from the heap must be explicitly freed to avoid leaks.
- File HandlingFile handling opens a stream in a chosen mode, reads or writes through it, and closes it to flush buffers and release the OS handle; the access mode determines whether the file is read, overwritten, or appended and whether it is text or binary.