Professional Documents
Culture Documents
History of C++
History of C++
PROGRAMMING FUNDAMENTALS
LECTURE # 5
E VOL UT I ON OF P ROG R AMMI NG L ANG UAGES
2
E VOL UT I ON OF P ROG R AMMI NG L ANG UAGES …
3
E VOL UT I ON OF P ROG R AMMI NG L ANG UAGES …
LOAD rate
MULT hour
STOR wages
4
E VOL UT I ON OF P ROG R AMMI NG L ANG UAGES …
5
ASSE MB LY & MACH I NE L ANG UAGE
CALL PRINT
10010001 01000100
6
COMP I L E R
7
COMP I L E R
• Source code
• The original program in a high level language
• Object code
• The translated version in machine language
8
L I NK ER S
• A Linker combines
• The object code for the programs we write
and
• The object code for the pre-compiled routines (of SDK)
into
• The machine language program the CPU can run
• Loader:
• Loads executable program into main memory
• The last step is to execute the program
9
H I STORY OF C & C+ +
• History of C
• Evolved from two other programming languages
10
H I STORY OF C & C+ +
• History of C++
• Object-oriented programs
• C++ programs are built from pieces called classes and functions
11
ST RUCT UR ED / OB J E CT-OR I ENTED P ROG R AMMI NG
• OOP
• “Software reuse”
• “Modularity”
• “Extensible”
• C++ systems
• Program-development environment
• Language
• .c (C)
13
C+ + STANDAR D L I BR ARY
15
PROG R AMMI NG ST Y L E ( CONT. )
16
C+ + K E Y WOR DS
bool, break, case, char, const, continue, do, default, double, else,
extern, false, float, for, if, int, long, namespace, return, short, static,
struct, switch, typedef, true, unsigned, void, while
17
ST RUCT UR E OF A C+ + P ROG R AM
• class definitions
18
G E NER AL FOR M OF A C+ + P ROG R AM
// Program description
#include directives
global declarations
int main()
{
constant declarations
variable declarations
executable statements
return 0;
}
19
I NCL UDES
#include "myfile.h"
21
C+ + COMP I L E R DI R E CT IV ES
22
P R E P ROC E SSOR
23
I NCL UDE STAT E ME NT S
25
T E ST I NG AND DE B UGGING
• Bug
• Debugging
26
P ROG R A M E R ROR S
• Syntax errors
• Violation of the grammar rules of the language
• Discovered by the compiler
• Error messages may not always show correct location of errors
• Run-time errors
• Error conditions detected by the computer at run-time
• Logical errors
• Errors in the program’s algorithm
• Most difficult to diagnose
• Computer does not recognize as an error
27
B AD PR ACT I CE OF P ROG R AMMI NG
28
DATA T Y P E S
29
SI MP L E DATA T Y P E S
30
SI MPL E DATA T Y P E S ( CONT ’ D. )
31
SI MPL E DATA T Y P E S ( CONT ’ D. )
32
I NT DATA T Y P E
Examples:
-6728
0
78
+763
33
B OOL DATA T Y P E
• bool type
• Logical values
• Reserved words
34
CH AR DATA T Y P E
• Written ' ', with a space left between the single quotes
35
FL OAT DATA T Y P E
36
FL OAT DATA T Y P E
75.924 7.592400E1
0.18 1.800000E-1
0.0000453 4.530000E-5
-1.482 -1.482000E0
7800.0 7.800000E3
37
DATA T Y P E S AND VAR I AB L ES
int counter;
double interestRate;
char grade;
38
END