Upload
omar-al-sabek
View
274
Download
0
Embed Size (px)
Citation preview
Pascal Programming Language
Omar ElSabek & Fayez GhazzawiIT Engineering3th year – UNKNOWN Department
Welcome!
Hope you are doing fine!
• Let’s think together !
• Why Pascal ?
• How we use the Pascal program ?
What Do we need !
• Test Question
• "Crack-the code" Section
• You need to try your self , otherwise
it won’t work out with u :(
• Practice , practice , practice …
Programming Paradigms
Variables
Control Structures
Loop Statements
Arrays
Functions
Course Index :
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.
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)
Programming Languages Wars
• 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
• Let’s try our First program
Program Lesson1_Program1 (input,output);
Var
Begin
End.
Program Lesson1_Program1 (input,output);
Var
Begin
End.
Program Lesson1_Program1 (input,output);
Begin
Writeln ( ‘ Hello World. Prepare to learn PASCAL!! ‘) ;
Readln ;
End.
Hello World. Prepare to learn PASCAL!!
• Read , Readln
Basic dealing structure for keyboard
• Write , Writeln
• 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
Variables Allocation:
Variables Allocation:
Variable Name : type Name ;
i: Integer;r: Real;b: Boolean;s: String[5];
i r
b
s
Variables Allocation:
Operator in Pascal !!
Multiply * Division /
Sum + subtract -
Operator in Pascal !!
Div : the right part of division
Mod : The remainder of the division
In addition !
Operator in Pascal !!
Mod work!
I mod J = I - ( I div J ) * J
(5 * 2) + 3 =
5 * 2 + 3 =
5 * (2 + 3) =
5 * 4 / 2 =
(5 * 4) / 2 =
5 * (4 / 2) =
13
13
25
10
10
10
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
• 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.
• Output!
• 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 …
• 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
برنامج الة حاسبة بسيطة يقوم بحساب العمليات األربعة لعددين
Calculate the area and Surroundings of circle