Book
Fundamental Programming with C, C++ and Python
Fundamental Programming with C, C++ and Python — Every program you have ever used was once a list of small, exact instructions that somebody wrote down: take this number, compare it with that one, repeat until the pile is empty, print the result. A computer is fast and tireless, but it does only what those instructions say — no more, no less, and never what you merely meant.
Overview
Chapters 1 to 3 build the ground: what a computer does and how a C program becomes a running one, with a full set-up of VS Code, a C compiler and Python on Windows, macOS and Linux; your first programs, variables in memory, arithmetic and decisions with if; then algorithms and pseudocode, the three control structures that are enough for any program, loops controlled by a counter or a sentinel, and top-down stepwise refinement; then for, do…while, switch, break and continue, the logical operators, and how to choose the right structure. Chapters 5 to 7 give programs their shape: functions, the standard library, scope and lifetime, repeatable randomness and recursion; arrays, used as counters, passed to functions, sorted with bubble sort, searched linearly and by halves, and laid out in two dimensions; and pointers, with pass-by-reference, output parameters, the close kinship of arrays and pointers, const, and pointers to functions. Chapters 9 to 11 let programs handle real data: characters, strings, <ctype.h>, the string library and its sharp edges, the full dial of printf and safe input; structures, enum and typedef, memory on demand with malloc and free, and a first linked list; and files, text and binary, the feof trap, reading a CSV line by line, append mode, random access, and saving without losing. Chapters 13 to 15 make the step to C++: streams, std::string, std::vector, references, overloading and new and delete; classes, with constructors and destructors that make every object born valid and cleaned up automatically, and a first look at inheritance; and operator overloading, with a money class and a fraction class, ending in a complete case study.
Chapters 4, 8, 12 and 16 are Evaluation and Discussion chapters. Each closes one quarter of the book by solving complete problems in full — every problem restated, designed on paper, programmed, tested, run, and explained — with the tempting wrong solution shown and taken apart, and a “check yourself” variant at the end of every problem. They range from areas of plane figures, a guessing game and rock, paper, scissors, through statistics, Fibonacci two ways, palindromes and a 3 × 3 determinant, to sorting a linked list, growing a tree from a file and a knight’s shortest path, and finally chess pieces as a class hierarchy, anagrams and matrix multiplication.
Throughout, one small business grows chapter by chapter: Profitina Laundry, a laundry on a busy lane in Surabaya, run by its owner Pak Hendra with Mbak Rina at the counter. It begins with receipts written by hand and a tired person multiplying weights by prices in her head. Its cashier program then grows one version per chapter: a first receipt with a minimum charge, a loop that serves customers until closing time, a price list for the wall, functions that hold every price in exactly one place, a day’s bills in an array, sorted and searched, names on the receipt, orders as records in a linked list, a day’s work that survives a power cut, and at last a complete shop written in C++ with classes and a money type that cannot go wrong. Each chapter also has a Using It for Real section that shows how the same ideas carry over to other small businesses and everyday problems.
Every program in this book was run before its output was printed. The programs are collected, chapter by chapter, in the accompanying Code folder, each chapter with its c (or cpp) and python versions side by side, its tests, and a README that explains how to build and run each one in a terminal and in VS Code on Windows, macOS and Linux. Every listing in the book is the file in that folder, character for character.
Inside the Book
- Computers, C and Your First Programs
- Structured Program Development: Algorithms, Pseudocode and Control
- Program Control: for, do…while, switch and Logical Operators
- Evaluation and Discussion I: Five Problems Solved Step by Step
- Functions: Divide, Name and Conquer
- Arrays: Many Values, One Name
- Pointers: Addresses as Values
- Evaluation and Discussion II: Functions, Arrays and Pointers, Solved Step by Step
- Characters, Strings and Formatted I/O
- Structures, Enums and a First Linked List
- File Processing: Data That Survives Power-Off
- Evaluation and Discussion III: Lists, Trees and a Knight
- C++ as a Better C
- Classes and Data Abstraction
- Operator Overloading and a Complete Case Study
- Evaluation and Discussion IV: Classes, Overloading and the Whole Book, Solved Step by Step
Profitina · profitina.com

