0% found this document useful (0 votes)
18 views74 pages

1.0 Intro - COMP208

The document provides an overview of computers and programming languages, detailing the definition of a computer, its components, and the evolution of programming languages. It covers hardware elements such as input/output devices, memory types, and the CPU, as well as software components like operating systems and language processors. Additionally, it discusses computing environments and methodologies related to programming.

Uploaded by

majdchazbek1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views74 pages

1.0 Intro - COMP208

The document provides an overview of computers and programming languages, detailing the definition of a computer, its components, and the evolution of programming languages. It covers hardware elements such as input/output devices, memory types, and the CPU, as well as software components like operating systems and language processors. Additionally, it discusses computing environments and methodologies related to programming.

Uploaded by

majdchazbek1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 74

An overview of computers and

programming languages

Dr. Rola Kassem


BAU - Debbiyeh
2

Outline
1. What is a computer?
2. Elements of a computer system
3. Computing environments
4. The language of a computer
5. The evolution of programming languages
6. Programming methodologies
7. History of C
8. The C standard library
9. A simple C program
10. Basics of a Typical C Program Development Environment

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
What is a computer? 3
Computer: an electronic device capable of performing
commands. The basic commands that a computer performs
are input (get data), output (display result), storage and
performance of arithmetic and logical operations.
n Be able to acquire or read data of all types
n Have the facility to store and organize data
n Be able to process data
n Have devices to output the processed data
n Be easily connectable to other computers using communication
networks for widely disseminating information

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
What is a computer? 3
Computer: an electronic device capable of performing
commands. The basic commands that a computer performs
are input (get data), output (display result), storage and
performance of arithmetic and logical operations.
n Be able to acquire or read data of all types
n Have the facility to store and organize data
n Be able to process data
n Have devices to output the processed data
n Be easily connectable to other computers using communication
networks for widely disseminating information
Input ACQUIR PROCES OUTPU Disseminate
STORE
data results
Numbers Data Data Data Result Numbers
Text acquisition storage processor display Text
Images units units (CPU) unit Images
Audio Audio
Video Video

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
4

Outline
1. What is a computer?
2. Elements of a computer system
3. Computing environments
4. The language of a computer
5. The evolution of programming languages
6. Programming methodologies
7. History of C
8. The C standard library
9. A simple C program
10. Basics of a Typical C Program Development Environment

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
Elements of a computer system (1) 5

n Hardware
• the machines, wiring, and other physical
components of your computer such as the
monitor, mouse, keyboard, ...

n Software
• the programs and other operating information
used by a computer

• program: a series of instructions to control the


operation of a computer

• software: a general term used to identify


programs, data, and other related files that are
used to accomplish certain tasks in a computer
system

User: a person who uses or


operates the computer such as
programmers, operators, ...
17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
Elements of a computer system (2) 6

Hardware: 1. Input devices:


n Keyboard:
• a panel of keys that operate a computer / used
to enter program and data for storage in the
computer’s memory

n Mouse:
• a small hand-held device that is dragged across
a flat surface to move the cursor on a computer
screen, typically having buttons that are pressed
to control computer functions

n Trackball:
• a small ball set in a holder that can be rotated
by hand to move a cursor on a computer screen

n Scanner - joysticks - ...


17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
Elements of a computer system (3) 7

Hardware: 2. Output devices:


n Video Display Unit or
Monitor:
• similar to a TV screen but is interactive

• used for outputting information in an


understandable format

• used to display small graphics symbols called


icons which assist you to give commands to the
computer (called Graphical User Interface, GUI)

n Speakers:
• used to produce music and other sounds

n Printers:
• a machine linked to a computer for printing text
or pictures onto paper

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
Elements of a computer system (4) 8

Hardware: 3. Memory:
n Random Access Memory (RAM) / main memory
hold the currently program being executed and the data currently
being processed
• read/write memory

• volatile memory

n Read Only Memory (ROM)


start up program that executes when the computer is turned on /
BIOS (Basic Input/Output System)
• non volatile memory

• can be read but not written

n Cache memory:
• a high speed memory that is used as a staging area for the processor

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
Elements of a computer system (5) 9

Measuring Memory:
Unit Abbreviation Size (bytes)

bit b 1/8

byte B 1

kilobyte KB 210 = 1024

megabyte MB 220 = 1,048,576

gigabyte GB 230 = 1,073,741,824

terabyte TB 240 = 1,099,511,627,776

petabyte PB 250 = 1,125,899,906,842,624

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
Elements of a computer system (6) 10

Hardware: 4. CPU:
n Central Processing Unit (CPU) / microprocessor
• the part of a computer in which operations (instructions) are controlled and
executed (data processing)

• speed is expressed in terms of MIPS (Millions of Instructions Per Second)

Today’s fastest
supercomputers can perform
hundreds of billions of
additions per second!

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
e200z1 Overview

Elements of a computer system (7)


.

11

OnCE/NEXUS
CPU

• CPU is partitioned into many CONTROL LOGIC


CONTROL LOGIC

subsystems:
MEMORY
- Instruction unit: controls the MANAGEMENT LR INTEGER
CR
flow of instructions UNIT SPR CTR GPR EXECUTION
UNIT
XER

Control unit: coordinates

ADDRESS
MULTIPLY
-

INSTRUCTION BUS INTERFACE UNIT


INSTRUCTION UNIT UNIT
different units INSTRUCTION BUFFER
CONTROL

32
- Integer unit, floating point unit:

DATA
EXTERNAL
used to process arithmetic and SPR
INTERFACE DATA
logical instructions. Adds,

32
(MTSPR/MFSPR)
subtracts, compares, shifts and
CONTROL
PC BRANCH
rotates UNIT UNIT

N LOAD/
STORE
- Load/store unit: executes UNIT
instructions that move data
between the GPRs and the
memory subsystem
DATA BUS INTERFACE UNIT

- ...
32 32 N
ADDRESS DATA CONTROL

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
Figure 1-1. e200z1 Block Diagram
so contains an instruction prefetch buffer to allow buffering of instruction
structions Elements ofbuffer
proceed from this a computer system
to the instruction decode(8) 12
stage by ente
de register IR.
Table 4-1. Pipeline Stages
n How CPU executes program?
Stage Description

IFETCH Instruction Fetch From Memory

DECODE/EA Instruction Decode / Register Read/ Operand


Forwarding / EA Calculation

EXECUTE/MEM Instruction Execution / Memory Access

WB Write Back to Registers

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
Elements of a computer system (9) 13

Hardware: 5. Secondary memory:


n Magnetic disc memories
➡ Hard disk:
• fast access and high capacity

• connected to the main memory

n Magnetic tape memories


• plastic tape with a magnetic coating

• store very large quantity of information

• low cost but long access time

• Modern usage is primarily as a high capacity medium for


backups and archives

• As of 2011, the highest capacity tape cartridges


(T10000C) can store 5 TB of uncompressed data

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
Elements of a computer system (10) 14

How hard drives work

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
Elements of a computer system (11) 15
Hardware: 5. Secondary memory:
n Optical disc memories
use a laser beam to enter data as spots on the disk surface. To read
data, the laser scans the disk and a lens picks up different light
reflections from the various spots

➡ CD-ROM:
• much slower than hard disk

• has a capacity of around half a billion characters

➡ DVD: contains minimum 4.7 GB

➡ Blu-Ray Disc (BD): contains 25 GB per layer

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
Elements of a computer system (12) 16

Speed

Cost
Size
17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
Elements of a computer system (13) 17
n Six logical units in every computer:
1. Input unit
• Obtains information from input devices (keyboard,
mouse)
2. Output unit
• Outputs information (to screen, to printer, to control other
devices)
3. Memory unit
• Rapid access, low capacity, stores input information
4. Arithmetic and logic unit (ALU)
• Performs arithmetic calculations and logic decisions
5. Central processing unit (CPU)
• Supervises and coordinates the other sections of the
computer
6. Secondary storage unit
• Cheap, long-term, high-capacity storage
• Stores inactive programs
17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
Elements of a computer system (14) 18

Software: commands the computer to perform actions and make decisions

Software

Application software Language processors

Operating system

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
Elements of a computer system (15) 19

Software: 1. Operating system:


n a program which acts as an interface
between a user & the hardware (i.e., all
computer resources): windows, Unix

n an important component of a computer


system which controls all other components
of the computer system

n The operating system perform the following


function:
✓ Provide the instruction to prepare user-interface
✓ Loads necessary program which are required for
proper computer functioning
✓ Manages the way information is stored on &
retrieved from disks

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
Elements of a computer system (16)
Evolution of Operating system: 20

n a Batch processing
– Do only one job or task at a time
– Users generally submitted their jobs to a computer center on decks of
punched cards

n Operating systems
– Manage transitions between jobs
– Increased throughput
• Amount of work computers process

n Multiprogramming
– Computer resources are shared by many jobs or tasks
– Users still submitted jobs on decks of punched cards

n Timesharing (in the 1960’s)


– Computer runs a small portion of one user’s job then moves on to service the
next user
– users access the computer through terminals, typically devices with
keyboards and screens
17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
Elements of a computer system (17) 21

Software: 2. Language processors:


n ASSEMBLER: converts the program written in assembly language
into machine language

n INTERPRETER: converts a HLL program into machine language


by converting it line- by- line. If there is any error in any line, it
reports it at the same time & program execution can not resume
until the error is rectified

n COMPILER: also converts the HLL program into machine


language. It converts the entire HLL program in one go, & reports
all the errors of the program along with the line numbers. After all
the errors are removed, the program is recompiled
3. Application software:
n the set of programs necessary to carry out operations for a
specified application, ex. play a game

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
22

Outline
1. What is a computer?
2. Elements of a computer system
3. Computing environments
4. The language of a computer
5. The evolution of programming languages
6. Programming methodologies
7. History of C
8. The C standard library
9. A simple C program
10. Basics of a Typical C Program Development Environment

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
Computing Environments (1) 23
n In the early days of computers, there was only one environment, the mainframe
computer hidden in a central computing department. With the advent of
minicomputers and personal computers, the environment changed with computers on
virtually every desktop. In this section we describe several different environments.

n Personal computers (1981, IBM)


– Economical enough for individual

n Distributed computing
– Computing distributed over
networks

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
Computing Environments (2) 24
n Client/server computing
– Sharing of information across computer networks between file servers
and clients (personal computers)

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
25

Outline
1. What is a computer?
2. Elements of a computer system
3. Computing environments
4. The language of a computer
5. The evolution of programming languages
6. Programming methodologies
7. History of C
8. The C standard library
9. A simple C program
10. Basics of a Typical C Program Development Environment

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
The language of a computer (1) 26

n The most commonly number system used by humans: Decimal


Number System (Base 10: 10 digits, 0 ⇾ 9)

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
The language of a computer (1) 26

n The most commonly number system used by humans: Decimal


Number System (Base 10: 10 digits, 0 ⇾ 9)
n Computers store data using binary
Number System:

➡ efficient to store

➡ easy to interpret by the hardware

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
The language of a computer (1) 26

n The most commonly number system used by humans: Decimal


Number System (Base 10: 10 digits, 0 ⇾ 9)
n Computers store data using binary
Number System:
Advanced technology is built on circuits and electric pulses
only two states are possible, either ON or OFF
➡ efficient to store

➡ easy to interpret by the hardware

OFF - 0 ON - 1

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
The language of a computer (1) 26

n The most commonly number system used by humans: Decimal


Number System (Base 10: 10 digits, 0 ⇾ 9)
n Computers store data using binary
Number System:
Advanced technology is built on circuits and electric pulses
only two states are possible, either ON or OFF
➡ efficient to store

➡ easy to interpret by the hardware

n Binary numbers take up space the


octal and hexadecimal number systems OFF - 0 ON - 1
are used to abbreviate them

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
The language of a computer (1) 26

n The most commonly number system used by humans: Decimal


Number System (Base 10: 10 digits, 0 ⇾ 9)
n Computers store data using binary
Number System:
Advanced technology is built on circuits and electric pulses
only two states are possible, either ON or OFF
➡ efficient to store

➡ easy to interpret by the hardware

n Binary numbers take up space the


octal and hexadecimal number systems OFF - 0 ON - 1
are used to abbreviate them

Binary System (Base 2): the form of encoding that allows


computers to run. It uses two states (represented by the
digits 0 and 1) to encode information
17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
The language of a computer (2) 27

Name Decimal Binary Octal Hexadecimal


Radix 10 2 8 16
0, 1, 2, 3, 4, 5, 6, 7,
0, 1, 2, 3, 4, 5, 6, 7
Digits 0, 1 0, 1, 2, 3, 4, 5, 6, 7 8, 9, A, B, C, D, E,
8, 9
F

0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
First 6 110 6 6
Seventeen 7 111 7 7
Positive 8 1000 10 8
Integers 9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
16 10000 20 10

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
The language of a computer (3) 28
Encoding of decimal numbers:
1110
Base
1 0 1 12
Most Significant Least Significant
Bit (MSB) Bit (LSB)
000 0
001 1
0 0 0
010 2
0 1 1 2 bits 4 different values 3 bits 8 different values
011 3
1 0 2 0⇾3 0⇾7
100 4
1 1 3
101 5
110 6
111 7

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
The language of a computer (3) 28
Encoding of decimal numbers:
1110
Base
1 0 1 12
Most Significant Least Significant
Bit (MSB) Bit (LSB)
000 0
001 1
0 0 0
010 2
0 1 1 2 bits 4 different values 3 bits 8 different values
011 3
1 0 2 0⇾3 0⇾7
100 4
1 1 3
101 5
110 6
111 7

n bits ⇒ 2n different values


0 ⇾ 2n - 1

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
The language of a computer (4) 29

Binary to decimal, decimal to binary conversion:


n Binary ⇾ decimal: multiply the value of each bit by its weight, then
add together the products
Example: the binary string 101, in decimal, comes to:
22x1 + 21x0 + 20x1 = 4x1 + 2x0 + 1x1= 5

n Decimal ⇾ binary: divide a given decimal number by 2 and make a


note of the remainder. Continue dividing, until you cannot divide by 2
anymore. When you note down the remainders starting from the
bottom, you get the binary number
Example: the decimal number 5, in binary, comes to:
5 ÷ 2 = 2 Remainder 1

2 ÷ 2 = 1 Remainder 0

1 ÷ 2 = 0 Remainder 1 0 1

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
The language of a computer (5) 30

Hexadecimal and octal representation:


n Octal: The octal base 8 is a power of the binary base 2 ( 8 = 2³ ) ⇒
binary conversion is very easy. All that is required is to split the binary
number into groups of 3, since 8 is 2 raised to the power of 3
Example: 6910 = 010001012 = 001 000 1012 = 1 0 58 (1×8² + 0×8 + 5 = 64 + 0 + 5 = 69)
n Hexadecimal: The hexadecimal base 16 is a power of the binary
base 2 ( 8 = 24 ) ⇒ binary conversion is even easier than from octal.
All that is required is to split the binary number into groups of 4, since
16 is 2 raised to the power of 4
Example: 6910 = 010001012 = 0100 01012 = 4 516 (4×16 + 5 = 64 + 5 = 69)

Since base 16 is being used, 16 digits are needed. There are only 10
decimal digits, so the capital letters A to F are used to represent the
numbers 10 to 15. A = 10, B = 11, up to F = 15.
Example: 1111 11112 = F F16 = 25510

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
The language of a computer (6) 31

Representation of characters:
n Numeric data: Using binary number system
n Non numeric data: Using standard encoding system:
➡ ASCII (American Standard Code for Information Interchange):
★ the most widely used code (personal computers)

★ uses 7 bits 128 characters (0 ⇾ 31: control characters)

➡ UNICODE (UNIversal CODE):


★ used to handle all the word’s languages

★ uses 17 planes of 16 bits each 17 * 65 536 = 1 114 112 different codes

➡ EBCDIC (Extended Binary Coded Decimal Interchange Code):


★ used on old IBM mainframes, completely different from ASCII
★ uses 8 bits 256 characters

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
The language of a computer (7) 32

ASCII:
Examples: 100 0001 is 41 (hex) or 65 (decimal). It represents 'A'
100 0010 is 42 (hex) or 66 (decimal). It represents 'B'

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
The language of a computer (7) 32

ASCII:
Examples: 100 0001 is 41 (hex) or 65 (decimal). It represents 'A'
100 0010 is 42 (hex) or 66 (decimal). It represents 'B'

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
The language of a computer (7) 32

ASCII:
Examples: 100 0001 is 41 (hex) or 65 (decimal). It represents 'A'
100 0010 is 42 (hex) or 66 (decimal). It represents 'B'

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
The language of a computer (8) 33

Exercises:
1. Convert the following decimal numbers to binary form:

1. 39

2. 512

2. Convert the following binary numbers to decimal:

1. 1101

2. 11011

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
The language of a computer (9) 34

Exercises:
3. Convert the following numbers to decimal:

1. 448

2. A9F16

3. 7548

4. Convert the following numbers to binary form:

1. 618

2. 3A916

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
35

Outline
1. What is a computer?
2. Elements of a computer system
3. Computing environments
4. The language of a computer
5. The evolution of programming languages
6. Programming methodologies
7. History of C
8. The C standard library
9. A simple C program
10. Basics of a Typical C Program Development Environment

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
The evolution of programming 36

languages (1)
n Computers process data under the control of sets of instructions called
computer programs need of programming languages
n Three types of programming languages:
1. Machine languages (1940’s)
• Strings of bits giving machine specific instructions
• Example: 100100 010001 Let’s consider the
100110 010010
equation:
100010 010011
wages = rate . hours
2. Assembly languages (1950’s)
• English-like abbreviations (called mnemonic) representing
elementary computer operations (translated via assemblers)
• Example:
LOAD rate Assembler: A program that translates a
ADD hours program written in assembly language into
STORE wages an equivalent program in machine language

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
The evolution of programming 37

languages (2)
3. High-level languages (1960’s)
• Codes similar to everyday English (translated via compilers)
• C, C++ and Java are all high-level languages
• Example:
in C, you write the weekly wages equation as follows:

wages = rate * hours;

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
The evolution of programming 37

languages (2)
3. High-level languages (1960’s)
• Codes similar to everyday English (translated via compilers)
• C, C++ and Java are all high-level languages
• Example:
in C, you write the weekly wages equation as follows:

wages = rate * hours;

Compiler: A program that translates a


program written in a high-level language
into an equivalent program in machine
language

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
components that model items in the real world. Using a modular, object-oriented design

The evolution of programming


and implementation approach can make software development groups more productive.
Chapters 15–24 present a condensed treatment of C++ selected from our book C++ 38
How to Program, 8/e. As you study C++, check out our online C++ Resource Center at
languages (3)
www.deitel.com/cplusplus/. Figure 1.6 introduces several other popular C-based pro-
gramming languages.
Other high-level languages:
Programming
language Description

Objective-C Objective-C is an object-oriented language based on C. It was developed in


the early 1980s and later acquired by NeXT, which in turn was acquired by
Apple. It has become the key programming language for the Mac OS X
operating system and all iOS-based devices (such as iPods, iPhones and
iPads).
Visual C# Microsoft’s three primary object-oriented programming languages are
Visual Basic, Visual C++ (based on C++) and C# (based on C++ and Java,
and developed for integrating the Internet and the web into computer
applications).
Java Sun Microsystems in 1991 funded an internal corporate research project
which resulted in the C++-based object-oriented programming language
called Java. A key goal of Java is to enable the writing of programs that will
run on a broad variety of computer systems and computer-controlled
devices. This is sometimes called “write once, run anywhere.” Java is used to
develop large-scale enterprise applications, to enhance the functionality of
web servers (the computers that provide the content we see in our web
browsers), to provide applications for consumer devices (smartphones, tele-
vision set-top boxes and more) and for many other purposes.

Fig. 1.6 | Popular C-based programming languages. (Part 1 of 2.)

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
The evolution of programming 39

14
languages (4)
Chapter 1 Introduction to Computers, the Internet and the Web
Other high-level languages:
Programming
language Description

PHP PHP—an object-oriented, open-source (see Section 1.12) scripting language


based on C and supported by a community of users and developers—is used
by many websites including Wikipedia and Facebook. PHP is platform inde-
pendent—implementations exist for all major UNIX, Linux, Mac and Win-
dows operating systems. PHP also supports many databases, including
MySQL. Other languages similar in concept to PHP are Perl and Python.
JavaScript JavaScript—developed by Netscape—is the most widely used scripting lan-
guage. It’s primarily used to add programmability to web pages—for exam-
ple, animations and interactivity with the user. It’s provided with all major
web browsers.

Fig. 1.6 | Popular C-based programming languages. (Part 2 of 2.)


n C++
1.9 Object Technology
– Superset of C developed by Bjarne Stroustrup at Bell Labs
Building software quickly, correctly and economically remains an elusive goal at a time
– "Spruces up" C,for
when demands and newprovides
and moreobject-oriented
powerful softwarecapabilities
are soaring. Objects, or more precisely
– the classeslanguage
Dominant objects come from, are essentially
in industry and academiareusable software components. There are date
objects, time objects, audio objects, video objects, automobile objects, people objects, etc.
– Because C++ includes C, some feel it is best to master C, then learn C++
Almost any noun can be reasonably represented as a software object in terms of attributes
17 Juin
Dr Kassem (e.g., name,
Rola 2010 color
An and size) of
overview andcomputers
behaviors (e.g.,
andcalculating,
programming movinglanguages
and communicating).
Software developers are discovering that using a modular, object-oriented design-and-
40

Outline
1. What is a computer?
2. Elements of a computer system
3. Computing environments
4. The language of a computer
5. The evolution of programming languages
6. Programming methodologies
7. History of C
8. The C standard library
9. A simple C program
10. Basics of a Typical C Program Development Environment

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
Programming methodologies 41

n Two popular approach:


➡ Structured programming (example: C): a problem is divided
into smaller subproblems. Each subproblem is solved, and the
solutions to all subproblems are then combined to solve the
problem
➡ Object-Oriented Programming (example: C++): a program is a
collection of interacting objects. An object consists of data and
operations on those data the key programming methodology
for the next decade

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
Programming methodologies 41

n Two popular approach:


➡ Structured programming (example: C): a problem is divided
into smaller subproblems. Each subproblem is solved, and the
solutions to all subproblems are then combined to solve the
problem
➡ Object-Oriented Programming (example: C++): a program is a
collection of interacting objects. An object consists of data and
operations on those data the key programming methodology
for the next decade

! Objects
– Reusable software components that model items in the real world
– Meaningful software units
- Date objects, time objects, audio objects,etc.
- Any noun can be represented as an object
– More understandable, better organized, and easier to maintain than
procedural programming

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
42

Outline
1. What is a computer?
2. Elements of a computer system
3. Computing environments
4. The language of a computer
5. The evolution of programming languages
6. Programming methodologies
7. History of C
8. The C standard library
9. A simple C program
10. Basics of a Typical C Program Development Environment

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
History of C 43
n The C programming language was designed by Dennis Ritchie at
Bell Laboratories in the early 1970s
n Evolved from two previous programming languages, BCPL and B
n Traditionally used to write operating systems and compilers / Used to
develop UNIX
n By late 1970's C had evolved to "Traditional C"
n Hardware independent (portable)
n Standardization:
➡ Many slight variations of C existed, and were incompatible
➡ Committee formed to create a "unambiguous, machine-independent" definition of the
language
➡ Standard created in 1989 by ANSI (American National Standards Institute) known as
ANSI C, updated by ISO (International Organization for Standardization ) in 1999 and
is known as C99
➡ In 2007, work began on another revision of the C standard, informally called "C1X"
until its official publication on 2011-12-08 C11
17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
History of C - Built for Performance 44
1.6 The C Programming Language 11
n C is widely used to develop systems that demand performance:
Application Description

Operating systems C’s portability and performance make it desirable for


implementing operating systems, such as Linux and
portions of Microsoft’s Windows and Google’s
Android. Apple’s OS X is built in Objective-C, which
was derived from C. We discuss some key popular
desktop/notebook operating systems and mobile
operating systems in Section 1.12.
Embedded systems The vast majority of the microprocessors produced
each year are embedded in devices other than general-
purpose computers. These embedded systems include
navigation systems, smart home appliances, home
security systems, smartphones, robots, intelligent traf-
fic intersections and more. C is one of the most popu-
lar programming languages for developing embedded
systems, which typically need to run as fast as possible
and conserve memory. For example, a car’s anti-lock
brakes must respond immediately to slow or stop the
car without skidding; game controllers used for video
games should respond instantaneously to prevent any
lag between the controller and the action in the game,
and to ensure smooth animations.
Real-time systems Real-time systems are often used for “mission-criti-
cal” applications that require nearly instantaneous
response times. For example, an air-traffic-control
system must constantly monitor the positions and
velocities of the planes and report that information to
air-traffic controllers without delay so that they can
alert the planes to change course if there’s a possibil-
ity of a collision.
Communications systems Communications systems need to route massive
amounts of data to their destinations quickly to
ensure that things such as audio and video are deliv-
ered smoothly and without delay.

Fig. 1.5 | Some popular performance-oriented C applications.


17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
45

Outline
1. What is a computer?
2. Elements of a computer system
3. Computing environments
4. The language of a computer
5. The evolution of programming languages
6. Programming methodologies
7. History of C
8. The C standard library
9. A simple C program
10. Basics of a Typical C Program Development Environment

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
The C standard library 46

n C programs consist of pieces/modules called functions

– A programmer can create his own functions


• Advantage: the programmer knows exactly how it works
• Disadvantage: time consuming
– Programmers will often use the C library functions
• Use these as building blocks
• Advantage: they save programming time, are carefully written to
perform optimally and increase program portability
– Avoid re-inventing the wheel
• If a function exists, generally best to use it rather than write
your own
• Library functions carefully written, efficient, and portable

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
47

Outline
1. What is a computer?
2. Elements of a computer system
3. Computing environments
4. The language of a computer
5. The evolution of programming languages
6. Programming methodologies
7. History of C
8. The C standard library
9. A simple C program
10. Basics of a Typical C Program Development Environment

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
A simple C program (1) 48

1 /* A first program in C */
2
3 #include <stdio.h>
4
5 /* function main begins program execution */
6 int main()
7 {
8 printf( "Welcome to C!\n" );
9
10 return 0; /* indicate that program ended successfully */
11
12 } /* end function main */

Welcome to C!

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
A simple C program (2) 49

1 /* A first program in C */
2
3 #include <stdio.h>
4
5 /* function main begins program execution */
6 int main()
7 {
8 printf( "Welcome to C!\n" );
9
10 return 0; /* indicate that program ended successfully */
11
12 } /* end function main */

Welcome to C!

n Comments:

– Text surrounded by /* and */ is ignored by computer


– Used to describe program

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
A simple C program (3) 50

1 /* A first program in C */
2
3 #include <stdio.h>
4
5 /* function main begins program execution */
6 int main()
7 {
8 printf( "Welcome to C!\n" );
9
10 return 0; /* indicate that program ended successfully */
11
12 } /* end function main */

Welcome to C!
n #include <stdio.h>

– Preprocessor directive
• Tells computer to load contents of a certain file
– <stdio.h> allows standard input/output operations

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
A simple C program (4) 51

1 /* A first program in C */
2
3 #include <stdio.h>
4
5 /* function main begins program execution */
6 int main()
7 {
8 printf( "Welcome to C!\n" );
9
10 return 0; /* indicate that program ended successfully */
11
12 } /* end function main */
Welcome to C!
n int main()
– C programs contain one or more functions, exactly one of which must be main
– Parenthesis used to indicate a function
– int means that main "returns" an integer value

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
A simple C program (4) 51

1 /* A first program in C */
2
3 #include <stdio.h>
4
5 /* function main begins program execution */
6 int main()
7 {
8 printf( "Welcome to C!\n" );
9
10 return 0; /* indicate that program ended successfully */
11
12 } /* end function main */
Welcome to C!
n int main()
– C programs contain one or more functions, exactly one of which must be main
– Parenthesis used to indicate a function
– int means that main "returns" an integer value

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
A simple C program (4) 51

1 /* A first program in C */
2
3 #include <stdio.h>
4
5 /* function main begins program execution */
6 int main()
7 {
8 printf( "Welcome to C!\n" );
9
10 return 0; /* indicate that program ended successfully */
11
12 } /* end function main */
Welcome to C!
n int main()
– C programs contain one or more functions, exactly one of which must be main
– Parenthesis used to indicate a function
– int means that main "returns" an integer value
– Braces ({ and }) indicate a block
• The bodies of all functions must be contained in braces
17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
A simple C program (4) 51

1 /* A first program in C */
2
3 #include <stdio.h>
4
5 /* function main begins program execution */
6 int main()
7 {
8 printf( "Welcome to C!\n" );
9
10 return 0; /* indicate that program ended successfully */
11
12 } /* end function main */
Welcome to C!
n int main()
– C programs contain one or more functions, exactly one of which must be main
– Parenthesis used to indicate a function
– int means that main "returns" an integer value
– Braces ({ and }) indicate a block
• The bodies of all functions must be contained in braces
17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
A simple C program (5) 52
1 /* A first program in C */
2
3 #include <stdio.h>
4
5 /* function main begins program execution */
6 int main()
7 {
8 printf( "Welcome to C!\n" );
9
10 return 0; /* indicate that program ended successfully */
11
12 } /* end function main */
Welcome to C!
n printf( "Welcome to C!\n" );
– Instructs computer to perform an action
• Specifically, prints the string of characters within quotes (" ")
– Entire line called a statement
• All statements must end with a semicolon (;)
– Escape character (\)
• Indicates that printf should do something out of the ordinary
• \n is the newline character
17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
A simple C program (5) 52
1 /* A first program in C */
2
3 #include <stdio.h>
4
5 /* function main begins program execution */
6 int main()
7
8
{
printf( "Welcome to C!\n" );
Do not
9 forget
10 return 0; /* indicate that program ended successfully */
11
12 } /* end function main */
Welcome to C!
n printf( "Welcome to C!\n" );
– Instructs computer to perform an action
• Specifically, prints the string of characters within quotes (" ")
– Entire line called a statement
• All statements must end with a semicolon (;)
– Escape character (\)
• Indicates that printf should do something out of the ordinary
• \n is the newline character
17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
A simple C program (6) 53

1 /* A first program in C */
2
3 #include <stdio.h>
4
5 /* function main begins program execution */
6 int main()
7 {
8 printf( "Welcome to C!\n" );
9
10 return 0; /* indicate that program ended successfully */
11
12 } /* end function main */
Welcome to C!
n return 0;
– A way to exit a function
– return 0, in this case, means that the program terminated normally

n Right brace }
– Indicates end of main has been reached
17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
A simple C program (7) 54

Write your C programs in a simple and straightforward manner.


This is sometimes referred to as “keep it simple”

Do not “stretch” the language by trying bizarre usages

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
55

Outline
1. What is a computer?
2. Elements of a computer system
3. Computing environments
4. The language of a computer
5. The evolution of programming languages
6. Programming methodologies
7. History of C
8. The C standard library
9. A simple C program
10. Basics of a Typical C Program Development Environment

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
Basics of a Typical C Program
56

Development Environment 1.10 Typical C Program Development Environment 17

Phase 1:

n Phases of C Programs: Editor


Disk
Programmer creates program
in the editor and stores it on
disk.

Phase 2:

1. Edit
Preprocessor Preprocessor program
Syntax error Disk
processes the code.

Phase 3:

2. Preprocess Compiler Compiler creates


Disk object code and stores
it on disk.
Phase 4:

3. Compile
Linker links the object
Linker code with the libraries,
Disk
creates an executable file and
stores it on disk.
Primary

4. Link Loader
Memory

5. Load Phase 5:
Loader puts program
in memory.

6. Execute

...
Disk

Primary
Memory
CPU
Phase 6:
CPU takes each
instruction and
executes it, possibly
storing new data
values as the program
executes.
...

Fig. 1.7 | Typical C development environment.


17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
Software Product
Figure 1.32 describes - Release
software product-release categories. Categories 57

Version Description

Alpha An alpha version is the earliest release of a software product that’s still under
active development. Alpha versions are often buggy, incomplete and unstable
and are released to a relatively small number of developers for testing new fea-
tures, getting early feedback, etc.
Beta Beta versions are released to a larger number of developers later in the devel-
opment process after most major bugs have been fixed and new features are
nearly complete. Beta software is more stable, but still subject to change.
Release Release candidates are generally feature complete and (supposedly) bug free and
candidates ready for use by the community, which provides a diverse testing environ-
ment—the software is used on different systems, with varying constraints and
for a variety of purposes. Any bugs that appear are corrected, and eventually
the final product is released to the general public. Software companies often
distribute incremental updates over the Internet.
Continuous Software that’s developed using this approach generally does not have version
beta numbers (for example, Google search or Gmail). The software, which is
hosted in the cloud (not installed on your computer), is constantly evolving
so that users always have the latest version.

Fig. 1.32 | Software product-release terminology.

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
58

Computer Communications

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
History of the Internet
59

n His grandparent was ARPAnet


n The Internet enables
n Quick and easy communication via e-mail

n International networking of computers

n Packet switching
n The transfer of digital data via small packets

n Allows multiple users to send and receive data simultaneously

n No centralized control
n If one part of the Internet fails, other parts can still operate

n TCP/IP
n Bandwidth
n Information carrying capacity of communications lines

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages
History of the World Wide Web
60

n World Wide Web


n Was developed years after the internet

n Locate and view multimedia-based documents on almost any


subject

n Makes information instantly and conveniently accessible


worldwide

n Possible for individuals and small businesses to get worldwide


exposure

n Changing the way business is done

17 Juin
Dr Rola 2010
Kassem An overview of computers and programming languages

You might also like