Programming Fundamentals
Instructor : Zuhair Qadir
Lecture # 5 1st-November-2013
1
Pro
gram
min
g Fu
nd
amen
tals
Programming Fundamentals
Lecture # 5
2
Pro
gram
min
g Fu
nd
amen
tals
Background
• Basic Concepts
• Computer Systems
• Computer Operations
• Problem Solving
• Data & Information
• Computer Program
• Programming Languages
• Compiler & Assembler
• Source Code & Object Code
11
/3/2
01
3
Pro
gra
mm
ing
Fu
nd
am
en
tals
4
S.No. Human Beings Computer System
1 Human Skeleton (Hardware) Physical parts (Hardware)
2 Soul Operating System
3 Brain for thinking Processor for processing
4 Things we can never forget in brain ROM
5 Things we can forget in brain RAM
6 Things that are stored permanent in brain
(our names and family members etc.)
Hard Disk/CD/DVD, etc.
7 Skull System Unit or Chip
8 Bones Components
9 Input through mouth, ears, eyes and
feelings, etc.
Input through Keyboard, Mouse,
Scanner, etc.
10 Output through eyes, hands, foots, tong,
fingers, etc.
Output through monitor, printer,
speaker, etc.
11 communication devices are tong, eyes,
fingers, etc.
Communication devices are Modem,
Network Interface Card, etc.
Comparison between Human Beings and Computer System
11
/3/2
01
3
Pro
gra
mm
ing
Fu
nd
am
en
tals
5
S.No. Human Beings Computer System
12 Different types of neurons operating in
human body(Motor, sensing and
transportation neurons, etc.
Different types of buses operating in
computer (Data, transport and address
buses etc.
13 Human body works in case of light off or
sleeping
It cannot works when power is off.
14 Blood is circulating Digital signals are circulating
15 Human system decides or work through his
own thinking or brainstorming
It is totally dependent on the program
instructions.
16 Human beings are trained by the teacher or
surroundings
It is trained by the programs (software)
only.
17 Human beings are dead without soul It is dead without an operating system.
18 Human beings can never be alive after death It can be used after the installation of an
operating system.
Comparison between Human Beings and Computer System
11
/3/2
01
3
Pro
gra
mm
ing
Fu
nd
am
en
tals
6
Background Hardware, Operating System and Application
Software
11
/3/2
01
3
Pro
gra
mm
ing
Fu
nd
am
en
tals
7
• Five main components • Input devices
• Allows the user to input data for processing
• Output devices • To display the output to the monitor or
getting printed copy
• Processor CPU CU ALU
AU LU
• Main memory • Memory locations containing the running
program
• Secondary memory • Permanent record of data often on a disk
Background Computer Systems
11
/3/2
01
3
Pro
gra
mm
ing
Fu
nd
am
en
tals
8
• Processor Typically called the CPU
• Central Processing Unit
• Follows program instructions
• Typical capabilities of CPU include: add subtract multiply divide move data from location to location
Background Computer Systems
11
/3/2
01
3
Pro
gra
mm
ing
Fu
nd
am
en
tals
9
Computer Input
Data
Output Solution
Information
Problem
Algorithm
Abstraction
Background Computer & Problem Solving
11
/3/2
01
3
Pro
gra
mm
ing
Fu
nd
am
en
tals
10
• Data: • Raw facts and figures provided as input to computer
• Information: • Data After Processing by computer is called information
Computer Data Information
Background Data & Information
11
/3/2
01
3
Pro
gra
mm
ing
Fu
nd
am
en
tals
11
• A computer program is… • A set of instructions written in a sequence to solve a particular
task.
• Computer software is … • The collection of programs used by a computer
• Includes: • Editors
• Translators
• System Managers
• Operating Systems
• Games etc
Background Computer Program
11
/3/2
01
3
Pro
gra
mm
ing
Fu
nd
am
en
tals
12
• Computer understands Machine Language
• ‘A’ may look like 01000001
• 65 may look like 01000001
• An instruction may look like 01000001
• Programming Languages
• Types
• High Level Languages (C, C++, Java, Pascal, Visual Basic, FORTRAN, COBOL, Lisp, Scheme, Ada)
• Low Level Languages (Assembly Language)
Background Programming Languages
11
/3/2
01
3
Pro
gra
mm
ing
Fu
nd
am
en
tals
13
• High – Level languages
• Resemble human languages
• Are designed to be easy to read and write
• Must be translated to zeros and ones for the CPU to execute a program
Background Programming Languages
11
/3/2
01
3
Pro
gra
mm
ing
Fu
nd
am
en
tals
14
• Low – Level Languages • An assembly language command such as
ADD X Y Z might mean add the values found at x and y in memory, and store the result in location z.
• Assembly language must be translated to machine language (zeros and ones) 0110 1001 1010 1011
• The CPU can follow machine language
Background Programming Languages
11
/3/2
01
3
Pro
gra
mm
ing
Fu
nd
am
en
tals
15
• Translate Programming language to machine language
Code in Programming
Language Language Translator
Code in Machine Language
Assembler (Translates low level or assembly language
program into machine code and also check errors)
Compiler (Translates High level language
program into machine code and also check errors)
Translator Types
Background Language Translators
11
/3/2
01
3
Pro
gra
mm
ing
Fu
nd
am
en
tals
16
• Translate high-level language to machine language
• Source code
• the original program in a high level language
• Object code
• the translated version in machine language
Source Code (Code in High Level
Language) Language Translator
Object Code
(Code in Machine Language)
Background Source Code and Object Code
11
/3/2
01
3
Pro
gra
mm
ing
Fu
nd
am
en
tals
17
#include<stdio.h>
Int main()
{
Cout<<“Hello”;
Return 0;
}
C++
Compiler 1011110100101
0101010101010
1111000011100
1010101010101
0101010101011
1100110011000
Background Language Translators