c++ programming language lecture 1 introduction by ghada al-mashaqbeh the hashemite university...

18
C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department

Upload: annabelle-black

Post on 31-Dec-2015

219 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department

C++ Programming LanguageLecture 1

Introduction

ByGhada Al-MashaqbehThe Hashemite UniversityComputer Engineering Department

Page 2: C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department

The Hashemite University 2

Outline Introduction. C++ overview. Computer organization and hardware

trends. Evolution of operating systems and

types of computing. Programming languages. Basics of a typical C++ environment.

Page 3: C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department

The Hashemite University 3

Introduction

In this course you will learn C++ and the legacy C code.

It is your first step in the software programming world.

It will provide you with the needed tools and background to learn object-oriented programming.

Page 4: C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department

The Hashemite University 4

What is C++?

A powerful programming language that enables you to write instructions (i.e. software) to drive the hardware of the computer (i.e. to perform actions and take decisions).

But first, what is computers? What is hardware? And what is software?

Page 5: C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department

The Hashemite University 5

What is a Computer? Computer

A device capable of performing computations and making logical decisions in a very fast manner.

Computer programs Sets of instructions that control a computer’s

processing of data Hardware

Various devices comprising a computer Examples: keyboard, screen, mouse, disks, memory,

CD-ROM, and processing units Software

Programs that run a computer

Page 6: C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department

The Hashemite University 6

Computer Organization Six logical units in every computer:

Input unit Obtains information from input devices (keyboard, mouse).

Output unit Outputs information (to screen, to printer, to control other

devices) Memory unit

Rapid access, low capacity, stores input information and programs while they are being executed (active programs and data).

Arithmetic and logic unit (ALU) Performs arithmetic calculations and logical decisions.

Central processing unit (CPU) Supervises and coordinates the other sections of the computer

(called the heart of the computer). Secondary storage unit

Cheap, long-term, high-capacity storage, stores inactive programs.

Page 7: C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department

The Hashemite University 7

Hardware Trends Every year or two computers

approximately double the following: The amount of memory they contain

Memory used to execute programs The amount of secondary storage they contain

Secondary storage (such as disk storage) is used to hold programs and data over time

Their processor speeds The speed at which computers execute their

programs This development is accompanied with a

decrease in prices and computers cost.

Page 8: C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department

The Hashemite University 8

Evolution of Operating Systems

Operating system (OS) is the intermediary software that lies between the hardware and the computer applications where it enables the interfacing between the user and the computer hardware.

Operating systems development: Batch processing

Do only one job or task or program at a time while processing data in groups or batches.

Operating systems Manage transitions between jobs. Increased throughput : Amount of work computers process. Still batch processing.

Multiprogramming Many jobs or tasks sharing a computer’s resources

Timesharing Special case of multiprogramming. Access computer resources via terminals. Perform a small portion of one user’s job then moves on to service

the next user

Page 9: C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department

The Hashemite University 9

Types of Computing

Personal computers Economical enough for individual

Distributed computing Organizations computing is distributed over

networks Client/server computing

Sharing of information across computer networks between servers (such as file servers, email servers, etc.) and clients (personal computers connected to the network)

Page 10: C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department

The Hashemite University 10

Programming Languages I

Three types of programming languages Machine languages

Strings of numbers giving machine specific instructions. Computers can only understand this language. Example:

101000110010011111111111111100000001110100

Machine dependent: every machine has its own language.

Hard to be understood by humans. Hard to be used in programming. Too slow and tedious. Error prone.

Page 11: C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department

The Hashemite University 11

Programming Languages II

Assembly languages English-like abbreviations representing elementary

computer operations so it is easier to be understood by humans.

Translated or converted into machine language via assemblers.

Also, it is slow and hard to be used in programming. Machine dependent. Example:

LOAD BASEPAYADD OVERPAYSTORE GROSSPAY

Page 12: C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department

The Hashemite University 12

Programming Languages III High-level languages

Similar to everyday English, use mathematical notations. Translated into machine language via compilers (compile

the whole program at once). Interpreters are used to execute high level languages

without need to compile them into machine language and it execute single line at a time.

Compiled programs are faster than the interpreted ones. Fast and easy for programming. Machine independent. Example:

grossPay = basePay + overTimePay

Page 13: C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department

The Hashemite University 13

Programming Languages IV

It is common to classify the computer programming languages into two types: Low level programming languages

which includes both the machine and assembly languages.

High level languages as in the previous slide.

Page 14: C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department

The Hashemite University 14

Example of High-level Languages Other high-level languages

C and C++. Java Visual basic 6/.Net C#.Net FORTRAN

Used in scientific and engineering applications COBOL

Used to manipulate large amounts of data Pascal

Used to teach structured programming

Page 15: C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department

The Hashemite University 15

History of C and C++ C++ evolved from C

C evolved from two other programming languages: BCPL and B which are used mainly to develop operating systems and compilers.

ANSI C: standard of C and C++ ANSI (American National Standard Institution ) has

cooperated with ISO (International Organization for Standardization) to established worldwide standards for C and C++ programming to make C++ programs portable.

C99 is the latest ANSI standard of C/C++ C++ “spruces up” C

Provides capabilities for object-oriented programming Objects are reusable software components that model

things in the real world Object-oriented programs are easy to understand, correct

and modify

Page 16: C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department

The Hashemite University 16

C++ Standard Library

C++ programs Built from pieces called classes and

functions. C++ standard library

Provides rich collections of existing classes and functions for all programmers to use.

Page 17: C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department

The Hashemite University 17

Basics of a Typical C++ Environment

Phases of C++ Programs:

1. Edit (create .h and .cpp files): create the source code or file

2. Preprocess

3. Compile: creates the object code

4. Link: creates the executable file

5. Load

6. Execute

Loader

PrimaryMemory

Program is created inthe editor and storedon disk.

Preprocessor programprocesses the code.

Loader puts programin memory.

CPU takes eachinstruction andexecutes it, possiblystoring new datavalues as the programexecutes.

CompilerCompiler createsobject code and storesit on disk.

Linker links the objectcode with the libraries,creates a.out andstores it on disk

Editor

Preprocessor

Linker

 CPU

PrimaryMemory

.

.

.

.

.

.

.

.

.

.

.

.

Disk

Disk

Disk

Disk

Disk

Page 18: C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department

The Hashemite University 18

Additional Notes

Check the Black Board to get your copy of the lecture.

The lecture covers the following sections from the textbook: Chapter 1: Sections 1.1 – 1.5, 1.8 –

1.10, and 1.15.