Abdul Karim Shahid (Akarim@cuilahore - Edu.pk)
Abdul Karim Shahid (Akarim@cuilahore - Edu.pk)
1
What are computers?
What is software?
What is programming?
Why programming?
Basic Concepts
Algorithms
Pseudo code
Flowcharts
First C program
Understanding the steps to write/run programs
Low and high level programming
Sli
de
2
Computer
◦ Device capable of performing computations and making logical
decisions
◦ Computers process data under the control of sets of instructions called
computer programs
Hardware
◦ Various devices comprising a computer
◦ Keyboard, screen, mouse, disks, memory, CD-ROM, and processing
units
Software
◦ Programs that run on a computer
System Software
Application Software
Sli
de
3
Sli
de
4
Sli
de
5
Tablet
Palmtop
Laptop
Desktop
And many more!!!
The distinction
◦ Scope of users
Programme (noun)
◦ Specific, countable
Software
◦ General, not countable
◦ Usually meant a collection of programs
Documenting the
program
◦ commenting
Formats
◦ Pseudo code
◦ Flow chart
Sli
de
29
Flow Lines Connectors
Flow Lines
Connectors
30
Example: The following set of instructions forms a
detailed algorithm in pseudo-code for calculating the
payment of person.
◦ Begin
◦ Input the three values into the variables Name, Hours, Rate.
◦ Calculate Pay = Hours * Rate.
◦ Display Name and Pay.
◦ End
Slide 31
Sli
de
32
(b) Pseudo code
Place 0 in sum
Place 0 in counter
Enter first number
DOWHILE the number is not equal to 999
Add number to sum
Add 1 to counter
Enter next number or 999
ENDDO
Divide sum by counter to get average
Write the average
How?
◦ Through a sequence of very clear and defined steps that aim to solve the
problem -> this is called an algorithm
Sli
de
34
Sentence by sentence, word by word
Detailed description in the chosen language
Sli
de
40
Generation First Second Third Fourth
1010101001
100010 body.top {
1001101010 color :
Code LDA 34 ADD
000001 x = x + 1 red; font-
example #1 STO 34
1111111110 style :
100010 italic }
Sli
de
41
Sli
de
42
Machine Language, Assembly Language
and High Level Language
Three types of programming languages
1. Machine languages
Strings of numbers giving machine specific instructions. Programs
written in machine language consist of entirely of 1s and 0s
Example:
00101010 000000000001 000000000010
10011001 000000000010 000000000011
2. Assembly languages
English-like abbreviations representing elementary computer operations
(translated via assemblers)
Example:
LOAD BASEPAY
ADD OVERPAY
STORE GROSSPAY
Sli
de
43
Machine Language, Assembly Language
and High Level Language
3. High-level languages
Codes similar to everyday English
Use mathematical notations (translated via compilers)
Example:
grossPay = basePay + overTimePay
Sli
de
44
Sli
de
45
‘C’ language was evolved by Dennis Ritchie (1972) from two previous
programming languages, BCPL and B at Bell Labs
Standard created in 1989 ( American National Standards Institute (ANSI)),
updated in 1999 (International Organization for Standardization (ISO))
C programs consist of pieces/modules called functions
A programmer can create his own functions
Programmers will often use the C library functions
Use these as building blocks
Avoid re-inventing the wheel
C++ A superset of C was developed by Bjarne Stroustrup at Bell Labs
Object Oriented Design of C++ - Code REUSABILITY
Because C++ includes C, it’s best to master C then learn C++
Other object oriented programming languages are: JAVA, COBOL 2002,
FORTRAN 2003 etc Sli
de
46
Sli
de
47
Sli
de
48
Sli
de
49
Sli
de
50
Program is created in the
Editor Disk editor and stored on disk.
Phases of C Programs:
Preprocessor program
Edit Preprocessor Disk processes the code.
Preprocessor
Compiler creates object code
Compile Compiler Disk and stores it on disk.
Link
Linker Linker links the object code
Load Disk with the libraries
Execute
Loader Physical Loader puts program in
Memory memory.
Disk
CPU takes each instruction
Physical and executes it, possibly
CPU storing new data values as
Memory
the program executes.
Sli
Slide 51 de
51
Sli
de
52
Sli
de
53