Stand at the Kamalapur railway counter for a minute and watch. The clerk types the number of passengers and the class of seat, presses a key, and a ticket comes out of the printer with the fare already worked out. Nobody in the booth multiplied anything. A program did: it took two numbers from the keyboard, kept them somewhere in memory, calculated, and printed the answer in a neat format. The bKash app that shows your balance, the result page that shows your marks and the calculator on your phone all do the same three things: they read values, keep them, and print what they work out.
This chapter is your first step into writing such programs yourself, and it assumes nothing. If you have never typed a line of code, that's fine; we start from an empty file. By the end you'll be able to write a small C program that reads a value, calculates and prints, and to say exactly what happens between the moment you save the file and the moment the answer appears. You'll know which names C accepts and why net-pay isn't one of them, which words belong to the language, how a variable lives in memory, how many bytes each data type takes and how far its values reach, why 0.1 + 0.2 is not exactly 0.3, and how to print and read every type with the right format specifier. These are the questions that open many programming papers, and they are among the easiest marks once the ideas are clear.
We'll go in five parts: the first program and its journey from text to running, the names a program uses, variables and constants, the data types with their sizes and ranges, and finally decimals, printing and reading. We'll write C, the language most exam questions use, with a word on Python and Java where they differ. Every program in this chapter was compiled and run, and the output you see is the real output.