Chapter 1
Chapter 1
INTRODUCTION TO
COMPUTER
PROGRAMS
Learning Outcomes
O
M • mainframes and supercomputers were available.
1975
P
U • IBM introduced its personal computers
1981
T
E • The first personal computer with a graphical user interface was introduced
1983
R
S
INTRODUCTION C++ PROGRAMMING All Rights Reserved
© Oxford Fajar Sdn. Bhd. (008974-T), 2015 1– 6
Basic Operation of a Computer
Hardware Software
Computer Component
❑ machine dependent
❑ Important in any program as they are very useful for documentation but it is
not compulsory to write comments in programs.
– Comments are not source code, thus they will not be read by the
compiler.
❑ Can be written in any way, according to the programmers’ preferences
❑ Explain the purpose, parts of the program and keep notes regarding
changes to the source code
❑ Store programmers’ name for future reference.
❑ Main Function
– Every C++ program contains one or more functions,
but one of it must be named as main .
– A function is a block of code that carries out specific
tasks.
– Generally, a main function starts with the function
type void or int before it is followed by the word
main and a pair of parentheses ().
– It is more advisable to write the function type int in
the main function but the word return 0 must be
written at the end of the function before it is closed.
❑ Braces
– Body of the main function which is enclosed in braces
{}.
• Used to mark the beginning and end of blocks of
code in any program.
• The open brace { is placed at the beginning of
code after the main function and the close brace }
is used to show the closing of code.
• The code after the } will not be read/evaluated by
the compiler.
❑ Statement
– A function consists of a sequence of statements that
perform the work of the function.
– Every statement in C++
ends with a semicolon (;).