computer engineering 2 nd semester dr. rabie a. ramadan 2

26
Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan http://rabieramadan.org/ classes/2011/prog/ 2

Upload: sandra-mcbride

Post on 17-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

Computer Engineering 2nd Semester

Dr. Rabie A. Ramadan

http://rabieramadan.org/classes/2011/prog/

2

Page 2: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

2

Class Rules

It will be a tough class , however,• Enjoy what you do

Do not worry about the exam as long as :• You are reading and understanding the materials in the book

I do not care how are you going to learn programming language

The section will help you to do so but it is your responsibility to dig in the subject

Page 3: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

3

Class Rules Attendance is a must

Assignments must be delivered on time no exception whatever the reason.

The source code must be submitted with any programming assignment

Page 4: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

Class Rules

You can bring anything to drink but NO FOOD PLEASE

When you come in , DO NOT knock on the door

When you want to leave , Do NOT tell me Just leave but you will counted as absent

Page 5: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

5

Class Information

Text Books• Rabie Ramadan , Computer Engineering for Developers, 2011

• Other sources

• Website

• http://www.rabieramadan.org/classes/2011/prog/

Page 6: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

Before We Start ….

25th of January

Be Smart

Page 7: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

Programming Language Programming Language

programming language is a tool used by a programmer to give the computer very specific instructions in order to serve some purpose for the user.

A program is like a recipe.

• mix eggs, butter, sugar in a bowl

• add flour, baking soda, and flavorings

• mix until creamy

• add chocolate chips

• bake in the oven.

Can you make chocolate cake out of this recipe ?Can you make chocolate cake out of this recipe ?

Page 8: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

Do we need more details ?Do we need more details ?

YesYes

• place two eggs in a bowl

• add 1.5 c. butter to the eggs..

• bake cookies for 10-12 minutes at 375 degrees or until brown

• Is there anything missing ?Is there anything missing ?• Well , it does not say how to put the eggs shelled or not. Well , it does not say how to put the eggs shelled or not.

• It adds some illustrations It adds some illustrations

Page 9: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

Computer ProgrammingComputer Programming

Computer does not understandComputer does not understand

You need to tell it every detailsYou need to tell it every details

Therefore, we have languages to tell the computer what to Therefore, we have languages to tell the computer what to do. do.

Page 10: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

Is it only one language ?Is it only one language ?

No,No,

There are many languages There are many languages

Each one is designed with a purpose in mind Each one is designed with a purpose in mind

Page 11: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

What is behind the high level What is behind the high level language? language?

Computer does not understand the high level language Computer does not understand the high level language

The program must be translated to the machine language The program must be translated to the machine language

Compiler / Interpreter Compiler / Interpreter

Source CodeSource Code Compiler / Interpreter Compiler / Interpreter Object CodeObject Code

Page 12: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

Compiler/ Interpreter Compiler/ Interpreter

Page 13: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

Why C++?Why C++?

C++ allows expression of abstract ideas

C++ is a third generation language that allows a programmer to express their ideas at a high level as compared to assembly languages.

C++ still allows a programmer to keep low-level control

it has some of the "feel" of an assembly language.

Page 14: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

Why C++?Why C++?

C++ has national standards (ANSI)

Code written in C++ that conforms to the national standards can be easily integrated with preexisting code.

C++ is reusable and object-oriented

C++ is widely used and taught

Page 15: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

Structure of a program

Page 16: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

Line separation

Page 17: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

Multiple instructions

Page 18: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

Type of Structuring

Page 19: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

Comments

Page 20: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

C++’ Names The name of a variable: Starts with an underscore “_” or a letter, lowercase or uppercase, such as a letter from a to z or from A to Z.

Examples are Name, gender, _Students, pRice

Can include letters, underscore, or digits. Examples keyboard, Master, Junction, Player1, total_grade, _Score_Side1

Page 21: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

C++’ Names

Cannot include special characters such as !, %, ], or $

Cannot include an empty space

Cannot be any of the reserved words

Should not be longer than 32 characters (although allowed)

Page 22: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

Reserved keywords

Page 23: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

Data Types

A Byte

Page 24: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

Data Types

Character

Page 25: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

Data Types

\

Page 26: Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan  2

Reading Assignment

26

Please Read:

•Program Structure, Variables, Data Types, and Constants

•Operators and Operands

•Basic Input/Output