Introduction
Introduction
Introduction
Objectives
Processing words
Playing Games
Browsing Internet
What is Programming?
What is Programming?
Translating Human-Readable
Programs to Machine Code
(Machine Instructions)
Extremely primitive:
Encoded as numbers:
Translating Human-Readable
Programs to Machine Code
(Assembler)
Translating Human-Readable
Programs to Machine Code
(Higher-level Languages)
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, World!" << endl;
return 0;
}
C++
defines a function.
Every C++ program must have one and only ONE main function.
Most C++ programs contain other functions besides main (more about
functions later).
The linker combines machine code with library code into an executable program.
The Edit-Compile-Run
Loop
This process reflects the way
programmers work
(shown as a flowchart)
Algorithms
A sequence of steps that is unambiguous,
executable, and terminating is called an algorithm.
Algorithms
The Software
Development Process
For each problem
the programmer goes
through these steps
An informal description
Not in a language that a computer can understand, but easily
translated into a high-level language (like C++).
The method described in pseudocode must be
Unambiguous
Executable
Terminating
Step 2a. Add one more than the preceding year's value
Step 2c. Calculate the new balance value, the preceding
balance value, multiplied by 1.05.
Balance (RM)
10,000
Flowchart - Example
Sub-process/function (Add Value)
balance <20k
False
Print year,
balance
End
True
Summary
1. A computer program is a sequence of instructions and
decisions.
2. Programming is the act of designing and implementing
computer programs.
3. Computer programs are stored as machine instructions in a
code that depends on the processor type.
4. High-level programming languages are independent of the
processor.
5. A syntax error is a part of a program that does not conform to
the rules of the programming language while logic errors are
errors in a program that executes without performing the
intended action.
6. The compiler translates C++ programs into machine code.
Summary
9.
10.
11.
References