1.1. Basic Computer Structure#

As you already know a program is a sequence of instructions to be executed by a computer. Several components in the computer help execute a program.

The basic structure of a computer

Fig. 1.1 The basic structure of a computer 1.#

The main memory stores the data and instructions that are currently being executed.

The central processing unit (CPU) executes instructions of a program. The CPU fetches instructions from the main memory, decodes them and execute them. Some instructions may require writing and reading data to and from the main memory. The CPU has two main components: arithmetic logic unit (ALU) and control unit (CU). The ALU is responsible for executing arithmetic operations such as addition and subtraction and logical operations such as comparisons \(<\), \(>\), etc., while the control unit is responsible for controlling the execution of instructions.

Some instructions executed require accessing input and output (I/O) devices. These devices are used to communicate with the outside world, for example, to take input from a user from a keyboard, or to provide output to a user on a monitor.

Next, let’s get started on how to write a program in C++.


1

Image taken from Snefru: Learning Programming with C.