The collection of programs used by a computer is referred to as the software for that computer. The actual physical machines that make up a computer installation are referred to as hardware.
The five main components of a computer are the input device(s), the output device(s), the processor (CPU), the main memory, and the secondary memory.
A computer has two kinds of memory: main memory and secondary memory. Main memory is used only while the program is running. Secondary memory is used to hold data that will stay in the computer before and/or after the program is run.
A computer’s main memory is divided into a series of numbered locations called bytes. The number associated with one of these bytes is called the address of the byte. Often, several of these bytes are grouped together to form a larger memory location. In that case, the address of the first byte is used as the address of this larger memory location.
A byte consists of eight binary digits, each either zero or one. A digit that can only be zero or one is called a bit.
A compiler is a program that translates a program written in a high-level language like C++ into a program written in the machine language that the computer can directly understand and execute.
A sequence of precise instructions that leads to a solution is called an algorithm. Algorithms can be written in English or in a programming language, like C++. However, the word algorithm is usually used to mean a sequence of instructions written in English (or some other human language, such as Spanish or Arabic).
Before writing a C++ program, you should design the algorithm (method of solution) that the program will use.
Programming errors can be classified into three groups: syntax errors, run-time errors, and logic errors. The computer will usually tell you about errors in the first two categories. You must discover logic errors yourself.
The individual instructions in a C++ program are called statements.
A variable in a C++ program can be used to name a number. (Variables are explained more fully in the next chapter.)
A statement in a C++ program that begins with cout <<
is an output statement, which tells the computer to output to the screen whatever follows the <<
.
A statement in a C++ program that begins with cin >>
is an input statement.