programming paradigms c1

33
Pascal Programming Language Omar ElSabek & Fayez G hazzawi IT Engineering 3 th year UNKNOWN Department

Upload: omar-al-sabek

Post on 16-Apr-2017

269 views

Category:

Education


0 download

TRANSCRIPT

Page 1: Programming paradigms c1

Pascal Programming Language

Omar ElSabek & Fayez GhazzawiIT Engineering3th year – UNKNOWN Department

Page 2: Programming paradigms c1

Welcome!

Hope you are doing fine!

Page 3: Programming paradigms c1

• Let’s think together !

• Why Pascal ?

• How we use the Pascal program ?

Page 4: Programming paradigms c1

What Do we need !

Page 5: Programming paradigms c1

• Test Question

• "Crack-the code" Section

• You need to try your self , otherwise

it won’t work out with u :(

• Practice , practice , practice …

Page 6: Programming paradigms c1

Programming Paradigms

Variables

Control Structures

Loop Statements

Arrays

Functions

Course Index :

Page 7: Programming paradigms c1

Programming Paradigms

• Moore's Law

• 30 years ago, Intel's cofounder, Gordon Moore, predicted that thecomputer processing power could be doubled every 18-24 months. Thisis measured by doubling the transistor count in a microprocessor. Thisprediction is now known as Moore s Law.

• Effects of Moore's Law on software

• Software applications ale becoming larger and more power at about thesame rate as hardware improvements allow.

• Language goals

• Bring modern approaches into the main stream in order to deal withthe increasing scale of programs - B. Stroustntp.

• To reduce development and maintenance cost new approaches inwriting programs were needed.

Page 8: Programming paradigms c1

Programming Paradigms

• A way to think about and organize computer data and code.

• Each paradigm has a set of languages.Categories of programming language paradigms:

• Imperative

• Procedural (e.g., Pascal, C)

• Object-oriented (e.g., C++,C#, Java)

• Declarative

• Functional (e.g., Lisp)

• Logic (e.g., Prolog)

Page 9: Programming paradigms c1

Programming Languages Wars

Page 10: Programming paradigms c1

• About The High Level Language Pascal

• Pascal is a high level computer language. That means that the programmer is highly removed from the actual machine code. Machine code, is the only language which a computer can really understand. Understanding, is maybe going too far, but any other language must go through some kind of translating stage before it can be run

Page 11: Programming paradigms c1

• Let’s try our First program

Page 12: Programming paradigms c1

Program Lesson1_Program1 (input,output);

Var

Begin

End.

Page 13: Programming paradigms c1

Program Lesson1_Program1 (input,output);

Var

Begin

End.

Page 14: Programming paradigms c1

Program Lesson1_Program1 (input,output);

Begin

Writeln ( ‘ Hello World. Prepare to learn PASCAL!! ‘) ;

Readln ;

End.

Hello World. Prepare to learn PASCAL!!

Page 15: Programming paradigms c1

• Read , Readln

Basic dealing structure for keyboard

• Write , Writeln

Page 16: Programming paradigms c1

• Constant :

have a specific value and have address in memory

• Variable :

It’s a specific place in memory with a name and address in memory

Page 17: Programming paradigms c1

Variables Allocation:

Page 18: Programming paradigms c1

Variables Allocation:

Page 19: Programming paradigms c1

Variable Name : type Name ;

i: Integer;r: Real;b: Boolean;s: String[5];

i r

b

s

Variables Allocation:

Page 20: Programming paradigms c1

Operator in Pascal !!

Multiply * Division /

Sum + subtract -

Page 21: Programming paradigms c1

Operator in Pascal !!

Div : the right part of division

Mod : The remainder of the division

In addition !

Page 22: Programming paradigms c1

Operator in Pascal !!

Mod work!

I mod J = I - ( I div J ) * J

Page 23: Programming paradigms c1
Page 24: Programming paradigms c1

(5 * 2) + 3 =

5 * 2 + 3 =

5 * (2 + 3) =

5 * 4 / 2 =

(5 * 4) / 2 =

5 * (4 / 2) =

13

13

25

10

10

10

Page 25: Programming paradigms c1

5 mod 2 =

2 mod 5 =

5 mod -2 =

-2 mod 5 =

-5 mod 2 =

2 mod -5 =

5 div 2 =

2 div 5 =

5 div -2 =

-2 div 5 =

-5 div 2 =

2 div -5 =

1

2

1

-2

-1

2

2

0

-2

0

-2

0

Page 26: Programming paradigms c1
Page 27: Programming paradigms c1

• Let’s see what you got!

Program Lesson1_Program1 (input,output);

Var

Sum , num1 , num2 : integer ;

Begin

writeln (‘please enter the First number’);readln (num1);writeln (‘please enter the second number’);readln (num2);sum := num1 + num2;writeln(num1 , ’+’ , num2 , ’=‘ , sum);

Readln ;

End.

Page 28: Programming paradigms c1

• Output!

Page 29: Programming paradigms c1

• Let’s see what you got!

Program Lesson1_Program1 (input,output);

Var

Sum , X ,Y : integer ;

Begin

………

End.

Program Lesson1_Program1 (input,output);

Var

Sum : integer ; X : integer ; Y : integer ;

Begin

………

End.

Is the same as …

Page 30: Programming paradigms c1

• Let’s see what you got!

Program Lesson1_Program1 (input,output);

Var

z , x , y : integer ;

Begin

Readln x;

Writeln x;

Z:= X * X ;

Y:= 4 * X ;

Writeln(Z , y);

readln;

End.

Calculate the area and Surroundings of square

Page 31: Programming paradigms c1
Page 32: Programming paradigms c1

برنامج الة حاسبة بسيطة يقوم بحساب العمليات األربعة لعددين

Calculate the area and Surroundings of circle

Page 33: Programming paradigms c1