SlideShare a Scribd company logo
1 of 37
Download to read offline
Pascal Programming Language
Omar ElSabek & Fayez Ghazzawi
IT Engineering
3th year – UNKNOWN Department
•How was last class? :D
•Happy with the course ?
•Any Q ?
• Conditional Sentences
• If / else Sentence
• Nested if Sentence
• CombinationTools
• Loop :D
• We use if to add a Condition to the operation.
• The General Form:
• So here … the Compiler will check the validity of the condition:
1. If true : the instructions inside the block will be implemented :)
2. Else : the instructions inside the block will not be seen :(
if (condition) then
begin
…
end ;
Program Lesson2_Program1 (input,output);
Var
x : integer;
Begin
read (x);
if (x > 10) then
begin
writeln ( ‘ x is bigger than 10 ’ ) ;
writeln ( ‘ x is too big ’ ) ;
end;
Readln ;
End.

• We use else after (if) condition to add another condition to the operation
if the (if) condition is not valid.
• The General Form:
• So there…The Compiler will check the validity of the condition:
1. If true : the instructions inside the (if) block will be implemented :)
2. Else : the instructions inside the (else) block will be implemented :)
if (condition) then
begin
…
end
else
begin
…
end;
Program Lesson2_Program1 (input,output);
Var
x : integer;
Begin
read (x);
if (x > 10) then
begin
writeln ( ‘ x is bigger than 10 ’ ) ;
end
else
begin
writeln (‘ x is smaller than 10 or equal to 10’);
end
Readln ;
End.

Program Lesson2_Program1 (input,output);
Var
x : integer;
Begin
read (x);
if (x > 10) then
begin
writeln ( ‘ x is bigger than 10 ’ ) ;
end
else
begin
writeln (‘ x is smaller than 10 or equal to 10’);
end
Readln ;
End.

Program Lesson2_Program1 (input,output);
Var
x : integer;
Begin
read (x);
if (x > 10) then
begin
writeln ( ‘ x is bigger than 10 ’ ) ;
end
else
begin
writeln (‘ x is smaller than 10 or equal to 10’);
end
Readln ;
End.

Note that if the 'else' term is included with an if statement, then
there should be No semi-colon before the 'else' term
just as seen in the above example. .
10
• Nested if is the case that there is an (if) inside another (if) ,we use this case to
check a condition after checking a previous one.
• The General Form is
• Here …The Compiler will check
the validity of condition1.
if condition1 is valid ,the compiler
will check the validity of condition2.
if (condition1) then
begin
…
if (condition2) then
begin
…
end
…
end
Program Lesson2_Program1 (input,output);
Var
x : integer;
Begin
read (x);
if (x > 10) then
begin
writeln (‘ x is bigger than 10’);
if (x > 20) then
writeln (‘x is bigger than 20’);
end;
End.

Program Lesson2_Program1 (input,output);
Var
x : integer;
Begin
read (x);
if (x > 10) then
begin
writeln (‘ x is bigger than 10’);
if (x > 20) then
writeln (‘x is bigger than 20’);
end;
End.

Program Lesson2_Program1 (input,output);
Var
x : integer;
Begin
read (x);
if (x > 10) then
begin
writeln (‘ x is bigger than 10’);
if (x > 20) then
writeln (‘x is bigger than 20’);
end;
End.

• We use these tools between the conditions in the same (if) sentence
1. AND operation:The block will not be implemented unless the two (or more) conditions
are valid.
General Form:
if (condition1) and (condition2) then
begin
….
end
2.OROperation:The block will not be implemented unless one of the two (or
more) conditions are valid.
General Form:
3.NotOperation:The block will be implemented if the reverse condition is
valid.
General Form:
if (condition1) or (condition2) then
begin
….
end
if ( not condition1) then
begin
….
end
1. We can ignore the (begin-end) instructions if the block has just
one instruction.
2. We can’t write a (;) before (else).
Program Lesson2_Program1 (input,output);
Var
x : integer;
Begin
read (x);
if (x > 10) and (x < 20) then
writeln (‘x is between 10 and 20’);
End.

Program Lesson2_Program1 (input,output);
Var
x : integer;
Begin
read (x);
if (x = 10) or (x = 20) then
begin
writeln (‘x is equal to 10 or is equal to 20’);
end;
End.

Program Lesson2_Program1 (input,output);
Var
x : integer;
Begin
read (x);
if ( not ( x > 10 ) ) then
begin
writeln (‘x is smaller than 10 or equal to 10’);
end;
End.

Loop is used to repeat the execution
of a set of instructions for at least
one time.
Repeat
..(code)
..(code)
..(code)
Until conditional
statement;
General Form:
Program Lesson2_Program1 (input,output);
Var
YN : String;
Begin
Writeln ( ‘Y (YES) or N(NO)? ‘ ) ;
Repeat {repeat the code for at least one time}
Readln(YN) ;
If YN = 'y' then Writeln(‘Welcome :D’);
If YN = 'n' then Writeln('Why not? Exiting...');
Until (YN = 'n');
End.

The for loop is a sort of
repeat-until loop.
But repeats a set of instructions
for a number of times.
For {variable} :={original value} to / downto {final value} do
{code…..}
{code…..}
General Form:
Program Lesson2_Program1 (input,output);
Var
Counter : Integer;
Begin
For Counter := 1 to 7 do {it's easy and fast!}
writeln ('for loop test :D ‘, Counter);
Readln;
End.

Program Lesson2_Program1 (input,output);
Var
Counter : Integer;
Begin
For Counter := 7 downto 1 do {it's easy and fast!}
writeln ('for loop test :D ‘, Counter);
Readln;
End.

1. The for loop execute from the first value to the last value
2. In case the start and end values was same the loop execute only
ones :D
3. The start and end values must be from the same type 
Program Lesson2_Program1 (input,output);
Begin
For i:=1 to 1 do
Writeln(‘I’m Learning Pascal :D');
End.
I’m Learning Pascal :D

For i:= 1 to 's' do
For i:= 10 to 3 do
For i:= 5 downto 10 do

Program Lesson2_Program1 (input,output);
Begin
For i:=1 to 10 do
Writeln('wajdy');
Writeln('essam');
End.
U tell me what is the Output ;)

The whileloop is executed while the
condition is true.
It is different from the 'Repeat-Until' loop
since the loop might not be executed for at
least one time.
While <condition is true> do
instruction 1;
instruction 2;
instruction 3;
End;
General Form:
Program Lesson2_Program1 (input,output);
Var
Ch : Char;
Begin
Writeln ( ‘ Press ''q'' to exit... ‘ ) ;
Readln (Ch);
While ( Ch <> ‘ q ‘ ) do
Begin
Writeln ( ‘ I told you press ''q'' to exit!! ‘ ) ;
Read(Ch);
End;
End.


‫رسالة‬ ‫بطباعة‬ ‫فيقوم‬ ‫عدد‬ ‫ندخل‬ ‫برنامج‬ ‫اكتب‬yes‫ويطبع‬ ‫زوجي‬ ‫كان‬ ‫اذا‬
No‫فردي‬ ‫كان‬ ‫اذا‬
‫عدد‬ ‫قراءة‬‫الطالب‬n‫لعالماتهم‬ ‫المتوسط‬ ‫وحساب‬ ‫وعالماتهم‬
Control structures c2 c3

More Related Content

What's hot

What's hot (18)

Loops in C Programming Language
Loops in C Programming LanguageLoops in C Programming Language
Loops in C Programming Language
 
Loops in C Programming | for Loop | do-while Loop | while Loop | Nested Loop
Loops in C Programming | for Loop | do-while Loop | while Loop | Nested LoopLoops in C Programming | for Loop | do-while Loop | while Loop | Nested Loop
Loops in C Programming | for Loop | do-while Loop | while Loop | Nested Loop
 
Loops
LoopsLoops
Loops
 
Iteration
IterationIteration
Iteration
 
Loops in c
Loops in cLoops in c
Loops in c
 
What is to loop in c++
What is to loop in c++What is to loop in c++
What is to loop in c++
 
java in Aartificial intelligent by virat andodariya
java in Aartificial intelligent by virat andodariyajava in Aartificial intelligent by virat andodariya
java in Aartificial intelligent by virat andodariya
 
Algorithm and Programming (Looping Structure)
Algorithm and Programming (Looping Structure)Algorithm and Programming (Looping Structure)
Algorithm and Programming (Looping Structure)
 
Algorithm and Programming (Branching Structure)
Algorithm and Programming (Branching Structure)Algorithm and Programming (Branching Structure)
Algorithm and Programming (Branching Structure)
 
Storage classes in c language
Storage classes in c languageStorage classes in c language
Storage classes in c language
 
Storage classes in C
Storage classes in C Storage classes in C
Storage classes in C
 
Types of loops in c language
Types of loops in c languageTypes of loops in c language
Types of loops in c language
 
Looping statement
Looping statementLooping statement
Looping statement
 
Storage classes
Storage classesStorage classes
Storage classes
 
Algorithm and Programming (Procedure and Function)
Algorithm and Programming (Procedure and Function)Algorithm and Programming (Procedure and Function)
Algorithm and Programming (Procedure and Function)
 
Loops
LoopsLoops
Loops
 
Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch cases
 
While , For , Do-While Loop
While , For , Do-While LoopWhile , For , Do-While Loop
While , For , Do-While Loop
 

Viewers also liked

Programming For As Comp
Programming For As CompProgramming For As Comp
Programming For As CompDavid Halliday
 
Double linked list c8
Double linked list c8Double linked list c8
Double linked list c8Omar Al-Sabek
 
How to modernize PR team workflow
How to modernize PR team workflowHow to modernize PR team workflow
How to modernize PR team workflowFrederik Vincx
 
Pascal tutorial
Pascal tutorialPascal tutorial
Pascal tutorialhidden__
 
Programming paradigms c1
Programming paradigms c1Programming paradigms c1
Programming paradigms c1Omar Al-Sabek
 
My PRstack – A practical guide to modern PR tools and workflow
My PRstack – A practical guide to modern PR tools and workflowMy PRstack – A practical guide to modern PR tools and workflow
My PRstack – A practical guide to modern PR tools and workflowPrezly
 
Pascal's Triangle slideshow
Pascal's Triangle slideshowPascal's Triangle slideshow
Pascal's Triangle slideshowecooperms
 
Meet the Peso Model, Your New Best Friend.
Meet the Peso Model, Your New Best Friend.Meet the Peso Model, Your New Best Friend.
Meet the Peso Model, Your New Best Friend.Ashley Incardone
 
PESO model visual communication planning cards and workflow
PESO model visual communication planning cards and workflowPESO model visual communication planning cards and workflow
PESO model visual communication planning cards and workflowFrederik Vincx
 
Pascal Programming Session 1
Pascal Programming Session 1Pascal Programming Session 1
Pascal Programming Session 1Ashesh R
 
Unleash your inner Public Relations geek
Unleash your inner Public Relations geekUnleash your inner Public Relations geek
Unleash your inner Public Relations geekPrezly
 

Viewers also liked (20)

Records c2
Records c2Records c2
Records c2
 
Files c4
Files c4Files c4
Files c4
 
Linked lists c7
Linked lists c7Linked lists c7
Linked lists c7
 
Files c3
Files c3Files c3
Files c3
 
Pointers c5
Pointers c5Pointers c5
Pointers c5
 
Programming For As Comp
Programming For As CompProgramming For As Comp
Programming For As Comp
 
Double linked list c8
Double linked list c8Double linked list c8
Double linked list c8
 
Stack c6
Stack c6Stack c6
Stack c6
 
How to modernize PR team workflow
How to modernize PR team workflowHow to modernize PR team workflow
How to modernize PR team workflow
 
Sets c1
Sets c1Sets c1
Sets c1
 
Pascal tutorial
Pascal tutorialPascal tutorial
Pascal tutorial
 
Programming paradigms c1
Programming paradigms c1Programming paradigms c1
Programming paradigms c1
 
My PRstack – A practical guide to modern PR tools and workflow
My PRstack – A practical guide to modern PR tools and workflowMy PRstack – A practical guide to modern PR tools and workflow
My PRstack – A practical guide to modern PR tools and workflow
 
Pascal's Triangle slideshow
Pascal's Triangle slideshowPascal's Triangle slideshow
Pascal's Triangle slideshow
 
Meet the Peso Model, Your New Best Friend.
Meet the Peso Model, Your New Best Friend.Meet the Peso Model, Your New Best Friend.
Meet the Peso Model, Your New Best Friend.
 
Pascal programming lecture notes
Pascal programming lecture notesPascal programming lecture notes
Pascal programming lecture notes
 
PESO model visual communication planning cards and workflow
PESO model visual communication planning cards and workflowPESO model visual communication planning cards and workflow
PESO model visual communication planning cards and workflow
 
Pascal Programming Session 1
Pascal Programming Session 1Pascal Programming Session 1
Pascal Programming Session 1
 
Pascal programming language
Pascal programming languagePascal programming language
Pascal programming language
 
Unleash your inner Public Relations geek
Unleash your inner Public Relations geekUnleash your inner Public Relations geek
Unleash your inner Public Relations geek
 

Similar to Control structures c2 c3

banaz hilmy.pptx
banaz hilmy.pptxbanaz hilmy.pptx
banaz hilmy.pptxBaNaz8
 
Loop and while Loop
Loop and while LoopLoop and while Loop
Loop and while LoopJayBhavsar68
 
computer programming and utilization
computer programming and utilizationcomputer programming and utilization
computer programming and utilizationJAYDEV PATEL
 
Programming fundamental 02
Programming fundamental 02Programming fundamental 02
Programming fundamental 02Suhail Akraam
 
C programming Control Structure.pptx
C programming Control Structure.pptxC programming Control Structure.pptx
C programming Control Structure.pptxDEEPAK948083
 
Constructs (Programming Methodology)
Constructs (Programming Methodology)Constructs (Programming Methodology)
Constructs (Programming Methodology)Jyoti Bhardwaj
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control StructureSokngim Sa
 
C++ control structure
C++ control structureC++ control structure
C++ control structurebluejayjunior
 
Basics of Control Statement in C Languages
Basics of Control Statement in C LanguagesBasics of Control Statement in C Languages
Basics of Control Statement in C LanguagesChandrakantDivate1
 
JPC#8 Introduction to Java Programming
JPC#8 Introduction to Java ProgrammingJPC#8 Introduction to Java Programming
JPC#8 Introduction to Java ProgrammingPathomchon Sriwilairit
 
Programming in java - Concepts- Operators- Control statements-Expressions
Programming in java - Concepts- Operators- Control statements-ExpressionsProgramming in java - Concepts- Operators- Control statements-Expressions
Programming in java - Concepts- Operators- Control statements-ExpressionsLovelitJose
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statementsSaad Sheikh
 
Loops in c language
Loops in c languageLoops in c language
Loops in c languageTanmay Modi
 
Lect3-C--EEB.pptx
Lect3-C--EEB.pptxLect3-C--EEB.pptx
Lect3-C--EEB.pptxKIJAMALEGI
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in JavaNiloy Saha
 
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medinaFundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medinarurumedina
 

Similar to Control structures c2 c3 (20)

banaz hilmy.pptx
banaz hilmy.pptxbanaz hilmy.pptx
banaz hilmy.pptx
 
Loop and while Loop
Loop and while LoopLoop and while Loop
Loop and while Loop
 
computer programming and utilization
computer programming and utilizationcomputer programming and utilization
computer programming and utilization
 
Programming fundamental 02
Programming fundamental 02Programming fundamental 02
Programming fundamental 02
 
C programming Control Structure.pptx
C programming Control Structure.pptxC programming Control Structure.pptx
C programming Control Structure.pptx
 
Constructs (Programming Methodology)
Constructs (Programming Methodology)Constructs (Programming Methodology)
Constructs (Programming Methodology)
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
 
C++ control structure
C++ control structureC++ control structure
C++ control structure
 
Basics of Control Statement in C Languages
Basics of Control Statement in C LanguagesBasics of Control Statement in C Languages
Basics of Control Statement in C Languages
 
While loop
While loopWhile loop
While loop
 
JPC#8 Introduction to Java Programming
JPC#8 Introduction to Java ProgrammingJPC#8 Introduction to Java Programming
JPC#8 Introduction to Java Programming
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Programming in java - Concepts- Operators- Control statements-Expressions
Programming in java - Concepts- Operators- Control statements-ExpressionsProgramming in java - Concepts- Operators- Control statements-Expressions
Programming in java - Concepts- Operators- Control statements-Expressions
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statements
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
 
Lect3-C--EEB.pptx
Lect3-C--EEB.pptxLect3-C--EEB.pptx
Lect3-C--EEB.pptx
 
C++ loop
C++ loop C++ loop
C++ loop
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
 
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medinaFundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
 

More from Omar Al-Sabek

More from Omar Al-Sabek (6)

Google Big Table
Google Big TableGoogle Big Table
Google Big Table
 
Online Certificate Data Mining with Weka
Online Certificate Data Mining with WekaOnline Certificate Data Mining with Weka
Online Certificate Data Mining with Weka
 
Agile Methodology
Agile MethodologyAgile Methodology
Agile Methodology
 
Git
GitGit
Git
 
E payment Project Demo
E payment Project DemoE payment Project Demo
E payment Project Demo
 
A petri-net
A petri-netA petri-net
A petri-net
 

Recently uploaded

PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxakanksha16arora
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use CasesTechSoup
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17Celine George
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Economic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food AdditivesEconomic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food AdditivesSHIVANANDaRV
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxCeline George
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111GangaMaiya1
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningMarc Dusseiller Dusjagr
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...EADTU
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 

Recently uploaded (20)

PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptx
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use Cases
 
Our Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdfOur Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Economic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food AdditivesEconomic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food Additives
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptx
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 

Control structures c2 c3

  • 1. Pascal Programming Language Omar ElSabek & Fayez Ghazzawi IT Engineering 3th year – UNKNOWN Department
  • 2. •How was last class? :D •Happy with the course ? •Any Q ?
  • 3. • Conditional Sentences • If / else Sentence • Nested if Sentence • CombinationTools • Loop :D
  • 4. • We use if to add a Condition to the operation. • The General Form: • So here … the Compiler will check the validity of the condition: 1. If true : the instructions inside the block will be implemented :) 2. Else : the instructions inside the block will not be seen :( if (condition) then begin … end ;
  • 5. Program Lesson2_Program1 (input,output); Var x : integer; Begin read (x); if (x > 10) then begin writeln ( ‘ x is bigger than 10 ’ ) ; writeln ( ‘ x is too big ’ ) ; end; Readln ; End. 
  • 6. • We use else after (if) condition to add another condition to the operation if the (if) condition is not valid. • The General Form: • So there…The Compiler will check the validity of the condition: 1. If true : the instructions inside the (if) block will be implemented :) 2. Else : the instructions inside the (else) block will be implemented :) if (condition) then begin … end else begin … end;
  • 7. Program Lesson2_Program1 (input,output); Var x : integer; Begin read (x); if (x > 10) then begin writeln ( ‘ x is bigger than 10 ’ ) ; end else begin writeln (‘ x is smaller than 10 or equal to 10’); end Readln ; End. 
  • 8. Program Lesson2_Program1 (input,output); Var x : integer; Begin read (x); if (x > 10) then begin writeln ( ‘ x is bigger than 10 ’ ) ; end else begin writeln (‘ x is smaller than 10 or equal to 10’); end Readln ; End. 
  • 9. Program Lesson2_Program1 (input,output); Var x : integer; Begin read (x); if (x > 10) then begin writeln ( ‘ x is bigger than 10 ’ ) ; end else begin writeln (‘ x is smaller than 10 or equal to 10’); end Readln ; End.  Note that if the 'else' term is included with an if statement, then there should be No semi-colon before the 'else' term just as seen in the above example. .
  • 10. 10 • Nested if is the case that there is an (if) inside another (if) ,we use this case to check a condition after checking a previous one. • The General Form is • Here …The Compiler will check the validity of condition1. if condition1 is valid ,the compiler will check the validity of condition2. if (condition1) then begin … if (condition2) then begin … end … end
  • 11. Program Lesson2_Program1 (input,output); Var x : integer; Begin read (x); if (x > 10) then begin writeln (‘ x is bigger than 10’); if (x > 20) then writeln (‘x is bigger than 20’); end; End. 
  • 12. Program Lesson2_Program1 (input,output); Var x : integer; Begin read (x); if (x > 10) then begin writeln (‘ x is bigger than 10’); if (x > 20) then writeln (‘x is bigger than 20’); end; End. 
  • 13. Program Lesson2_Program1 (input,output); Var x : integer; Begin read (x); if (x > 10) then begin writeln (‘ x is bigger than 10’); if (x > 20) then writeln (‘x is bigger than 20’); end; End. 
  • 14. • We use these tools between the conditions in the same (if) sentence 1. AND operation:The block will not be implemented unless the two (or more) conditions are valid. General Form: if (condition1) and (condition2) then begin …. end
  • 15. 2.OROperation:The block will not be implemented unless one of the two (or more) conditions are valid. General Form: 3.NotOperation:The block will be implemented if the reverse condition is valid. General Form: if (condition1) or (condition2) then begin …. end if ( not condition1) then begin …. end
  • 16. 1. We can ignore the (begin-end) instructions if the block has just one instruction. 2. We can’t write a (;) before (else).
  • 17. Program Lesson2_Program1 (input,output); Var x : integer; Begin read (x); if (x > 10) and (x < 20) then writeln (‘x is between 10 and 20’); End. 
  • 18. Program Lesson2_Program1 (input,output); Var x : integer; Begin read (x); if (x = 10) or (x = 20) then begin writeln (‘x is equal to 10 or is equal to 20’); end; End. 
  • 19. Program Lesson2_Program1 (input,output); Var x : integer; Begin read (x); if ( not ( x > 10 ) ) then begin writeln (‘x is smaller than 10 or equal to 10’); end; End. 
  • 20.
  • 21.
  • 22. Loop is used to repeat the execution of a set of instructions for at least one time.
  • 24. Program Lesson2_Program1 (input,output); Var YN : String; Begin Writeln ( ‘Y (YES) or N(NO)? ‘ ) ; Repeat {repeat the code for at least one time} Readln(YN) ; If YN = 'y' then Writeln(‘Welcome :D’); If YN = 'n' then Writeln('Why not? Exiting...'); Until (YN = 'n'); End. 
  • 25. The for loop is a sort of repeat-until loop. But repeats a set of instructions for a number of times.
  • 26. For {variable} :={original value} to / downto {final value} do {code…..} {code…..} General Form:
  • 27. Program Lesson2_Program1 (input,output); Var Counter : Integer; Begin For Counter := 1 to 7 do {it's easy and fast!} writeln ('for loop test :D ‘, Counter); Readln; End. 
  • 28. Program Lesson2_Program1 (input,output); Var Counter : Integer; Begin For Counter := 7 downto 1 do {it's easy and fast!} writeln ('for loop test :D ‘, Counter); Readln; End. 
  • 29. 1. The for loop execute from the first value to the last value 2. In case the start and end values was same the loop execute only ones :D 3. The start and end values must be from the same type 
  • 30. Program Lesson2_Program1 (input,output); Begin For i:=1 to 1 do Writeln(‘I’m Learning Pascal :D'); End. I’m Learning Pascal :D 
  • 31. For i:= 1 to 's' do For i:= 10 to 3 do For i:= 5 downto 10 do 
  • 32. Program Lesson2_Program1 (input,output); Begin For i:=1 to 10 do Writeln('wajdy'); Writeln('essam'); End. U tell me what is the Output ;) 
  • 33. The whileloop is executed while the condition is true. It is different from the 'Repeat-Until' loop since the loop might not be executed for at least one time.
  • 34. While <condition is true> do instruction 1; instruction 2; instruction 3; End; General Form:
  • 35. Program Lesson2_Program1 (input,output); Var Ch : Char; Begin Writeln ( ‘ Press ''q'' to exit... ‘ ) ; Readln (Ch); While ( Ch <> ‘ q ‘ ) do Begin Writeln ( ‘ I told you press ''q'' to exit!! ‘ ) ; Read(Ch); End; End. 
  • 36.  ‫رسالة‬ ‫بطباعة‬ ‫فيقوم‬ ‫عدد‬ ‫ندخل‬ ‫برنامج‬ ‫اكتب‬yes‫ويطبع‬ ‫زوجي‬ ‫كان‬ ‫اذا‬ No‫فردي‬ ‫كان‬ ‫اذا‬ ‫عدد‬ ‫قراءة‬‫الطالب‬n‫لعالماتهم‬ ‫المتوسط‬ ‫وحساب‬ ‫وعالماتهم‬