Introduction
Every computer program, no matter how large, is built from three simple ideas: it stores data (variables and types), it decides what to do (conditional control flow), and it repeats work (loops). If you understand these three ideas precisely, you can read and reason about almost any code fragment an exam throws at you.
For BCS, Bank IT, and IT-officer written and MCQ exams, this topic is a guaranteed source of marks. Questions ask you to trace a small program (predict the exact output), to know the size and range of a data type, to spot integer-division and type-casting traps, and to convert between loop forms. This lesson builds every idea from first principles so you never guess — you compute the answer.
Learning Objectives
- Define a variable, an identifier, a literal, and understand memory storage of a value.
- Distinguish data types (integer, floating-point, character, boolean, string) and know typical sizes and ranges.
- Understand type systems: static vs dynamic typing, strong vs weak typing, and type casting (implicit vs explicit).
- Evaluate expressions using operator precedence and associativity, including integer division and modulo.
- Master control flow: sequence, selection (if / else if / switch), and iteration (for / while / do-while).
- Trace a program by hand and predict its exact output.
- Avoid the classic exam traps: off-by-one, overflow,
=vs==, and floating-point rounding.