Programming Lecture 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 27

Computer Programming

Lecture 1
INTRODUCTION TO COMPUTERS AND C++

Dr. Badria Nabil

1
Course Objectives
Conceptual Skills: Recognize the main concepts of computer
programming using C++ programming language.

Practical Skills: Practice how to use C++ program by writing a C++


program on the editor and correct errors and run the program.

General Skills:
◦ Building your logical schema by learning how to think logically.

2
Course Grades Distribution
The total grade 100
◦ Mid-term Exam 30
◦ Final-term Exam 40
◦ Class Work 30 (15 Lecture + 15 Section)
◦ Lecture : 15 degrees distribution
◦ 5 Assignments
◦ 5 Quizzes
◦ 5 Class participation

3
Introduction
Computer System

4
What is a Computer System?
It is an electronic device which designed to accept data,
processing it and display the results (information) of these
operations to make a specific task.

processing
Inputs Output

data Information

Storage

5
Processing?

Mathematical
Logical Operations
Calculations
(< > = )
(+ - * /)

6
Data VS Information
•Data: are raw facts or observations, typically about physical
phenomena or business transactions.
• Ex: Data generated from student record (student code, name, tel ,
address, grades…)

•Information: a processed data placed in a context that gives


it value for specific end users.
• Ex: What are the information generated from the previous business
transaction? ( List of students by groups, sorted list by grades)

7
Binary system
How Data is Stored?
For example, character ‘J’ is Memory address Memory content
represented by 01001010 in one
byte.
. .
A small number such as three can . .
be stored in a single byte. . .
If computer needs to store a large 2000 01001010 Encoding for character ‘J’
number that cannot fit into a 2001 01100001 Encoding for character ‘a’
single byte, it uses a number of 2002 01110110 Encoding for character ‘v’
adjacent bytes. 2003 01100001 Encoding for character ‘a’
2004 00000011 Encoding for number 3
No two data can share or split a
same byte. A byte is the minimum
storage unit.
Bit is 1 or 0
1 Byte = 8 bits
8
The components of the
computer system
•People (End users, IT Specialists)
•Hardware
•Software
•Data
•Communication

9
Components of Computer System
Hardware resources: Includes all physical devices
used in information processing. (computer systems
and its peripherals)
Memory(RAM)

Input devices Central Processing Unit(CPU)


(keyboard,
Output devices
mouse,mic,camera, Arithmetic & (Monitor, Printer,
scanner) Speaker)
Logic Unit(ALU)

Control Unit(CU)

Storage
10
Computer Organization
Six logical units of computer
◦ Input unit
◦ “Receiving” section
◦ Obtains information from input devices
◦ Keyboard, mouse, microphone, scanner, networks, etc.
◦ Output unit
◦ “Shipping” section
◦ Places information processed by computer on output devices
◦ Screen, printer, networks, etc.
◦ Information can also be used to control other devices

11
Computer Organization (Cont.)
Six logical units of computer (Cont.)
◦ Memory unit
◦ Rapid access, relatively low capacity “warehouse” section
◦ Retains information from input unit
◦ Immediately available for processing
◦ Retains processed information
◦ Until placed on output devices
◦ Often called memory or primary memory
◦ Arithmetic and logic unit (ALU)
◦ “Manufacturing” section
◦ Performs arithmetic calculations and logic decisions

12
Computer Organization (Cont.)
Six logical units of computer (Cont.)
◦ Central processing unit (CPU)
◦ “Administrative” section
◦ Coordinates and supervises other sections of computer
◦ Secondary storage unit
◦ Long-term, high-capacity “warehouse” section
◦ Stores inactive programs or data
◦ Secondary storage devices
◦ Hard drives, CDs, DVDs
◦ Slower to access than primary memory
◦ Less expensive per unit than primary memory

13
Components of Computer System
Software resources
◦ Instructions to command computer to perform actions and make
decisions.
◦ Written by people called computer programmers
It includes:
◦ System software: Such as operating system(Windows, Android,
iOS, Unix, Linux)which controls and support the operations of a
computer system.
◦ Application software: which direct processing for a particular
use of computers by end users such as Office, payroll
programs, inventory programs.
◦ Procedures: which are operating instructions for the people who
will use an information system such as installation wizards ,
program help….

14
Types of computer languages

15
Types of computer languages
Three types of computer languages
◦ 1. Machine language
◦ Only language computer directly understands
◦ “Natural language” of computer
◦ Defined by hardware design
◦ Generally consist of strings of numbers
◦ Ultimately reduced to 0s and 1s
◦ Instruct computers to perform elementary operations
◦ Example
For example, to add two numbers, you might write an instruction in
binary like this:
◦ 1101101010011010

16
Types of computer languages
Three types of computer languages (Cont.)
◦ 2. Assembly language
◦ English-like abbreviations representing elementary computer operations
◦ Clearer to humans
◦ Incomprehensible to computers
◦ Convert to machine language by translator programs (assemblers)
◦ Example
◦ load A,B
add A,B
store Sum

17
Types of computer languages
Three types of computer languages (Cont.)
◦ 3. High-level languages
◦ Similar to everyday English
◦ Uses common mathematical notations
◦ Machine independent or portable software
◦ The ability to run on a variety of computers.
◦ Converted to machine language by translator programs (compilers)
◦ Interpreter programs
◦ Directly execute high-level language programs
◦ Execute more slowly than the compiled program
◦ Example
◦ grossPay = basePay + overTimePay

18
19
20
Compilers

21
Compilers
•A Compiler: is a program that translates source code (the program in
HLL) into object code (the program in machine language).
•The compiler is looking at the entire piece of source code and collecting
and reorganizing the instructions.
•It does not start translation if there are errors in the program.
•It requires some time before an executable program emerges
(Compilation time).
•This process can be time-consuming if the program is long.
•However, programs produced by compilers run much faster than the
same programs executed by an interpreter.

22
23
Interpreters
•It analyzes and executes each line of source code in succession (line by
line), without looking at the entire program. (No compilation time)
•So, if there is an error in the program, It starts translation until reaching
the line which contains this error and gives the programmer a message
to correct it.
•Both interpreters and compilers are available for most high-level
languages.

24
25
26
Popular High-Level Languages

27

You might also like