You are on page 1of 13

FP 201

Programming
Fundamentals
CHAPTER 1 : INTRODUCTION TO
C++ PROGRAMMING
1.1 Introducing the C++ Programming
Environment

1.1.1 History of C++


1973
Dennis Ritchie developed the basis of C
Features : arrays and pointers, capable of
portability.
1980
Bjarne Stroustrup ( Bell Labs ) began
development of C++

1.1.1 History of C++ (cont.)


1985
In October, first commercial release of C++

appeared with the launch of The C++


Programming Language by Bjarne Stroustrup.

1985+
C++ language refined until became a language

with own personality


C++ lived a great expansion in its uses and
today is still the preferred language to develop
professional applications on all platform.

1st Assignment
What are the differences between the C

language and C++? In your opinion, which


language is better?
Brief description on C language
Describe C++
Features

1.1.2 C++ Program Structure


preprocessor directives
main function heading
{
declarations
executable statements
}

#include
<iostream>
int main( )
{
//
statement(s);
}

1.1.3 C++ Programming


Development Process
1.
2.
3.
4.
5.
6.
7.
8.
9.

Identify the problem


Analyze the program
Analyze the data
Decide I/O for the entire program
Choose suitable algorithmic approach
Translation of the algorithm Coding
Compile and linking
Click on the STAR to
Test the program
view
*Debug if necessary
( when program does not generate desired results )

1.1.4 Integrated Development


Environment (IDE)
Definition : A software application that provides

comprehensive facilities to computer programmers


for software development.
An IDE consists of :
Source editor
Compiler and / or Interpreter
Build automation tools
Debugger

Examples of IDE : Eclipse, Microsoft Visual Studio,

WinDev, XCode, Bloodshed Dev C++.

FP 201
Programming
Fundamentals
CHAPTER 1 : INTRODUCTION TO
C++ PROGRAMMING
1.2 Identifying the Compiling & Debugging
Process, Errors in Programming

1.2.1 Compiling Process


Compiler
Translate the whole program at one time.
Translates the source code, for example C
language to machine language.
# include <iostream>
main( )
{
int x, y, z, sum;
double avg;
cout <<" Enter 3
numbers:";
cin >> x >>y>>z;
sum = x + y + z;
avg = sum / 3;
cout <<avg;
return 0;
}

C
C
Languag
Languag
e
e

Compiler

11101 100000 100000


11110
10111000
11101000
11111100
10111000
10001110
11011000
11000000
Machine
Machine
Langeage
Langeage

1.2.2 Errors in
Programming
Compile-time errors
Occurs when the rules of programming
language are not applied
Correction is done during the program coding
The bug can be traced during the compilation
Also known as syntax error
Must be corrected before executing and testing
the program

1.2.2 Errors in Programming (cont.)


Run-time errors
Cannot be traced by compiler
Occur while program runs, when the program
attempts an operation that is impossible to
carry out.
Also known as logic error
Example division by zero

1.2.2 Errors in Programming (cont.)


Logical errors
An error caused by following an incorrect
algorithm
Very difficult to detect - it does not cause runtime error and does not display message
errors
The only sign of logic error incorrect program
output
Can be detected by testing the program
thoroughly, comparing its output to calculated
results
To prevent carefully desk checking the

Lab 1
Debugging
programs
with compile
time, run
time and
logical errors.

You might also like