SlideShare a Scribd company logo
Pascal Programming Language
Omar ElSabek & Fayez Ghazzawi
IT Engineering
3th year – UNKNOWN Department
•Quiet!!!!!!!!!!
•Pay the fine! :P :D
•Being late!
•Talking!
•Procedures and Functions
• The most important material
• which are very important and you
should keep on practicing more
often.
• Pascal provides two kinds of subprograms:
•Functions : these subprograms return a single value.
•Procedures : these subprograms do not return a value directly.
•Proceduresare just like small programs.
• Sometimes they are called sub--programs.They help the programmer to avoid
repetitions.
• A procedure start off with a begin and ends up with an end;.
• It can also have its own variables, which cannot be used with the main-program.
Procedure Procedure name( Var Variable Name : Type );
Program Lesson1_Program1 (input,output);
Var
Procedure Square(X : Integer; Var y : Integer);
var
Begin
…………
End;
Begin
………….
End.
New knowledge aboutVariables !
There is aTwo type of Variables :
Global Variables :
That which we define in ProgramVar
Local Variable :
ThatWhich we define inside of our procedure/function or
in procedure/function signature
What is the signature !!!
What is the signature !!!
Procedure Procedure name( Var Variable Name : Type );Var Variable Name : Type
What is the prototype {define} !!!
What is the prototype !!!
Procedure Procedure name( Var Variable Name : Type );
Program Lesson1_Program1 (input,output);
Var
Z :integer ;
Procedure Square(X : Integer; Var y : Integer);
var
moxo :real ;
Begin
…………
End;
Begin
………….
End.
Program Lesson1_Program1 (input,output);
Var
Z :integer ;
Procedure Square(X : Integer ; Var y : Integer);
var
moxo :real ;
Begin
…………
End;
Begin
………….
End.
When you declare parameters to a
procedure, variables must separated
by a semi-colon ";".They are put in
between the brackets, following the
procedure name.
Program Lesson1_Program1 (input,output);
Var
X , Z : integer ;
Procedure Square(R : Integer ; Var Result : Integer);
Begin
Result := R * R ;
End;
Begin
Readln(X);
Square(X,Z);
Writeln('The square of X is: '); Writeln( Z );
End.
Program Lesson1_Program1 (input,output);
Var
X , Z : integer ;
Procedure Square(R : Integer);
Var
Result : Integer;
Begin
Result := R * R ;
writeln ('The square of X is: ' , Result);
End;
Begin
Readln(X);
Square(X);
End.
•Let’sTalk a little bit a bout our built in function !!
• ABS( -5 ) 5
• Chr( 97 ) a
• Ord( ‘ a ’ ) 97
• Sin(x) Cos(x)
• Pred( 6 ) 5
• Sqr( 3 ) 9
• Sqrt( 9 ) 3
• Odd( 3 ) True
• Even( 3 ) False
• Succ ( 5 ) 6
• Round( 3.14 ) 3
• Round( 3.64 ) 4
•FunctionareThe second type of sub-program .
• The only difference from the procedure is that the Function return a value at the
end.
• A Function start off with a begin and ends up with an end;.
• It can also have its own variables, which cannot be used with the main-program.
Function FunctionName(Var VariableName:Type): Return Type;
Program Lesson1_Program1 (input,output);
Var
Function Square(X : Integer): Integer ;
var
Begin
…………
End;
Begin
………….
End.
Program Lesson1_Program1 (input,output);
Var
X , Z : integer ;
Function Square(R : Integer) : Integer;
Begin
Square := R * R ;
End;
Begin
Readln(X);
Z:= Square(X);
Writeln('The square of X is: '); Writeln( Z );
End.

More Related Content

What's hot

Loops
LoopsLoops
Different loops in C
Different loops in CDifferent loops in C
Different loops in C
Md. Arif Hossain
 
C++ loop
C++ loop C++ loop
C++ loop
Khelan Ameen
 
Iteration
IterationIteration
Iteration
Liam Dunphy
 
Storage classes in C
Storage classes in C Storage classes in C
Storage classes in C
Self employed
 
Storage classes in c language
Storage classes in c languageStorage classes in c language
Storage classes in c language
tanmaymodi4
 
Loops in C Programming Language
Loops in C Programming LanguageLoops in C Programming Language
Loops in C Programming Language
Mahantesh Devoor
 
Algorithm and Programming (Looping Structure)
Algorithm and Programming (Looping Structure)Algorithm and Programming (Looping Structure)
Algorithm and Programming (Looping Structure)
Adam Mukharil Bachtiar
 
Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in JavaJin Castor
 
The Loops
The LoopsThe Loops
The Loops
Krishma Parekh
 
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
Priyom Majumder
 
Loops
LoopsLoops
Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch casesMeoRamos
 
Storage Classes and Functions
Storage Classes and FunctionsStorage Classes and Functions
Storage Classes and FunctionsJake Bond
 
Storage classes
Storage classesStorage classes
Storage classes
Puneet Rajput
 
C++ decision making
C++ decision makingC++ decision making
C++ decision making
Zohaib Ahmed
 

What's hot (19)

Loops
LoopsLoops
Loops
 
Different loops in C
Different loops in CDifferent loops in C
Different loops in C
 
C++ loop
C++ loop C++ loop
C++ loop
 
Iteration
IterationIteration
Iteration
 
Storage classes in C
Storage classes in C Storage classes in C
Storage classes in C
 
Storage classes in c language
Storage classes in c languageStorage classes in c language
Storage classes in c language
 
Loops in C Programming Language
Loops in C Programming LanguageLoops in C Programming Language
Loops in C Programming Language
 
Algorithm and Programming (Looping Structure)
Algorithm and Programming (Looping Structure)Algorithm and Programming (Looping Structure)
Algorithm and Programming (Looping Structure)
 
Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in Java
 
Loops in c
Loops in cLoops in c
Loops in c
 
The Loops
The LoopsThe Loops
The Loops
 
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
 
Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch cases
 
Looping statements
Looping statementsLooping statements
Looping statements
 
Storage Classes and Functions
Storage Classes and FunctionsStorage Classes and Functions
Storage Classes and Functions
 
Storage classes
Storage classesStorage classes
Storage classes
 
C++ decision making
C++ decision makingC++ decision making
C++ decision making
 
Turbo pascal
Turbo pascalTurbo pascal
Turbo pascal
 

Viewers also liked

Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Adam Mukharil Bachtiar
 
Internet, Email, Operating System Concepts2
Internet, Email, Operating System Concepts2Internet, Email, Operating System Concepts2
Internet, Email, Operating System Concepts2Nisa Peek
 
Gimp-manimaran
Gimp-manimaranGimp-manimaran
Gimp-manimaran
rmanimaran
 
Functions in python
Functions in pythonFunctions in python
Functions in pythonIlian Iliev
 
Ligtas at Responsableng Paggamit ng Computer, Internet at Email
Ligtas at Responsableng Paggamit ng Computer, Internet at EmailLigtas at Responsableng Paggamit ng Computer, Internet at Email
Ligtas at Responsableng Paggamit ng Computer, Internet at Email
Marie Jaja Tan Roa
 
G.C.E O/L ICT Short Notes Grade-11
G.C.E O/L ICT Short Notes Grade-11G.C.E O/L ICT Short Notes Grade-11
G.C.E O/L ICT Short Notes Grade-11
Mahesh Kodituwakku
 
Pascal Programming Language
Pascal Programming LanguagePascal Programming Language
Pascal Programming Language
Reham AlBlehid
 
Presentation1.Ppt Email And Internet
Presentation1.Ppt Email And InternetPresentation1.Ppt Email And Internet
Presentation1.Ppt Email And Internetaggregate
 
Pascal Programming Session 1
Pascal Programming Session 1Pascal Programming Session 1
Pascal Programming Session 1Ashesh R
 
Pascal programming language
Pascal programming languagePascal programming language
Pascal programming language
Mahesh Kodituwakku
 
Introduction of Cloud computing
Introduction of Cloud computingIntroduction of Cloud computing
Introduction of Cloud computing
Rkrishna Mishra
 

Viewers also liked (11)

Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
 
Internet, Email, Operating System Concepts2
Internet, Email, Operating System Concepts2Internet, Email, Operating System Concepts2
Internet, Email, Operating System Concepts2
 
Gimp-manimaran
Gimp-manimaranGimp-manimaran
Gimp-manimaran
 
Functions in python
Functions in pythonFunctions in python
Functions in python
 
Ligtas at Responsableng Paggamit ng Computer, Internet at Email
Ligtas at Responsableng Paggamit ng Computer, Internet at EmailLigtas at Responsableng Paggamit ng Computer, Internet at Email
Ligtas at Responsableng Paggamit ng Computer, Internet at Email
 
G.C.E O/L ICT Short Notes Grade-11
G.C.E O/L ICT Short Notes Grade-11G.C.E O/L ICT Short Notes Grade-11
G.C.E O/L ICT Short Notes Grade-11
 
Pascal Programming Language
Pascal Programming LanguagePascal Programming Language
Pascal Programming Language
 
Presentation1.Ppt Email And Internet
Presentation1.Ppt Email And InternetPresentation1.Ppt Email And Internet
Presentation1.Ppt Email And Internet
 
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
 
Introduction of Cloud computing
Introduction of Cloud computingIntroduction of Cloud computing
Introduction of Cloud computing
 

Similar to Function procedure c6 c7

Algorithm and Programming (Procedure and Function)
Algorithm and Programming (Procedure and Function)Algorithm and Programming (Procedure and Function)
Algorithm and Programming (Procedure and Function)
Adam Mukharil Bachtiar
 
Programming paradigms c1
Programming paradigms c1Programming paradigms c1
Programming paradigms c1
Omar Al-Sabek
 
Programming
ProgrammingProgramming
Programming
Leo Simon Anfone
 
python.pdf
python.pdfpython.pdf
python.pdf
BurugollaRavi1
 
C Language Lecture 16
C Language Lecture 16C Language Lecture 16
C Language Lecture 16
Shahzaib Ajmal
 
Introduction to Programming and QBasic Tutorial
Introduction to Programming and QBasic TutorialIntroduction to Programming and QBasic Tutorial
Introduction to Programming and QBasic Tutorial
nhomz
 
Logic Programming and ILP
Logic Programming and ILPLogic Programming and ILP
Logic Programming and ILP
Pierre de Lacaze
 
A brief introduction to C Language
A brief introduction to C LanguageA brief introduction to C Language
A brief introduction to C Language
Mohamed Elsayed
 
Introduction to R for Learning Analytics Researchers
Introduction to R for Learning Analytics ResearchersIntroduction to R for Learning Analytics Researchers
Introduction to R for Learning Analytics Researchers
Vitomir Kovanovic
 
Uni texus austin
Uni texus austinUni texus austin
Uni texus austin
N/A
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
PARADIGM IT.pptx
PARADIGM IT.pptxPARADIGM IT.pptx
PARADIGM IT.pptx
jamesmarken1
 
Unit I - 1R introduction to R program.pptx
Unit I - 1R introduction to R program.pptxUnit I - 1R introduction to R program.pptx
Unit I - 1R introduction to R program.pptx
SreeLaya9
 
C fundamentals
C fundamentalsC fundamentals
Should i Go there
Should i Go thereShould i Go there
Should i Go there
Shimi Bandiel
 
Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013
Prof. Wim Van Criekinge
 
Basic Computer Programming
Basic Computer ProgrammingBasic Computer Programming
Basic Computer Programming
Allen de Castro
 
02 Algorithms and flowcharts - computers.pptx
02 Algorithms and flowcharts - computers.pptx02 Algorithms and flowcharts - computers.pptx
02 Algorithms and flowcharts - computers.pptx
arifaqazi2
 

Similar to Function procedure c6 c7 (20)

Algorithm and Programming (Procedure and Function)
Algorithm and Programming (Procedure and Function)Algorithm and Programming (Procedure and Function)
Algorithm and Programming (Procedure and Function)
 
Programming paradigms c1
Programming paradigms c1Programming paradigms c1
Programming paradigms c1
 
Programming
ProgrammingProgramming
Programming
 
python.pdf
python.pdfpython.pdf
python.pdf
 
C Language Lecture 16
C Language Lecture 16C Language Lecture 16
C Language Lecture 16
 
programming.ppt
programming.pptprogramming.ppt
programming.ppt
 
Introduction to Programming and QBasic Tutorial
Introduction to Programming and QBasic TutorialIntroduction to Programming and QBasic Tutorial
Introduction to Programming and QBasic Tutorial
 
Logic Programming and ILP
Logic Programming and ILPLogic Programming and ILP
Logic Programming and ILP
 
A brief introduction to C Language
A brief introduction to C LanguageA brief introduction to C Language
A brief introduction to C Language
 
Introduction to R for Learning Analytics Researchers
Introduction to R for Learning Analytics ResearchersIntroduction to R for Learning Analytics Researchers
Introduction to R for Learning Analytics Researchers
 
Uni texus austin
Uni texus austinUni texus austin
Uni texus austin
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
PARADIGM IT.pptx
PARADIGM IT.pptxPARADIGM IT.pptx
PARADIGM IT.pptx
 
Unit I - 1R introduction to R program.pptx
Unit I - 1R introduction to R program.pptxUnit I - 1R introduction to R program.pptx
Unit I - 1R introduction to R program.pptx
 
C fundamentals
C fundamentalsC fundamentals
C fundamentals
 
Should i Go there
Should i Go thereShould i Go there
Should i Go there
 
Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013
 
Basic Computer Programming
Basic Computer ProgrammingBasic Computer Programming
Basic Computer Programming
 
02 Algorithms and flowcharts - computers.pptx
02 Algorithms and flowcharts - computers.pptx02 Algorithms and flowcharts - computers.pptx
02 Algorithms and flowcharts - computers.pptx
 

More from Omar Al-Sabek

Google Big Table
Google Big TableGoogle Big Table
Google Big Table
Omar Al-Sabek
 
Online Certificate Data Mining with Weka
Online Certificate Data Mining with WekaOnline Certificate Data Mining with Weka
Online Certificate Data Mining with Weka
Omar Al-Sabek
 
Agile Methodology
Agile MethodologyAgile Methodology
Agile Methodology
Omar Al-Sabek
 
Git
GitGit
E payment Project Demo
E payment Project DemoE payment Project Demo
E payment Project Demo
Omar Al-Sabek
 
A petri-net
A petri-netA petri-net
A petri-net
Omar Al-Sabek
 
Sets c1
Sets c1Sets c1
Sets c1
Omar Al-Sabek
 
Records c2
Records c2Records c2
Records c2
Omar Al-Sabek
 
Files c3
Files c3Files c3
Files c3
Omar Al-Sabek
 
Files c4
Files c4Files c4
Files c4
Omar Al-Sabek
 
Pointers c5
Pointers c5Pointers c5
Pointers c5
Omar Al-Sabek
 
Stack c6
Stack c6Stack c6
Stack c6
Omar Al-Sabek
 
Linked lists c7
Linked lists c7Linked lists c7
Linked lists c7
Omar Al-Sabek
 
Double linked list c8
Double linked list c8Double linked list c8
Double linked list c8
Omar Al-Sabek
 

More from Omar Al-Sabek (14)

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
 
Sets c1
Sets c1Sets c1
Sets c1
 
Records c2
Records c2Records c2
Records c2
 
Files c3
Files c3Files c3
Files c3
 
Files c4
Files c4Files c4
Files c4
 
Pointers c5
Pointers c5Pointers c5
Pointers c5
 
Stack c6
Stack c6Stack c6
Stack c6
 
Linked lists c7
Linked lists c7Linked lists c7
Linked lists c7
 
Double linked list c8
Double linked list c8Double linked list c8
Double linked list c8
 

Recently uploaded

Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 

Recently uploaded (20)

Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 

Function procedure c6 c7

  • 1. Pascal Programming Language Omar ElSabek & Fayez Ghazzawi IT Engineering 3th year – UNKNOWN Department
  • 2. •Quiet!!!!!!!!!! •Pay the fine! :P :D •Being late! •Talking!
  • 3. •Procedures and Functions • The most important material • which are very important and you should keep on practicing more often.
  • 4. • Pascal provides two kinds of subprograms: •Functions : these subprograms return a single value. •Procedures : these subprograms do not return a value directly.
  • 5. •Proceduresare just like small programs. • Sometimes they are called sub--programs.They help the programmer to avoid repetitions. • A procedure start off with a begin and ends up with an end;. • It can also have its own variables, which cannot be used with the main-program. Procedure Procedure name( Var Variable Name : Type );
  • 6. Program Lesson1_Program1 (input,output); Var Procedure Square(X : Integer; Var y : Integer); var Begin ………… End; Begin …………. End.
  • 8. There is aTwo type of Variables : Global Variables : That which we define in ProgramVar Local Variable : ThatWhich we define inside of our procedure/function or in procedure/function signature
  • 9. What is the signature !!!
  • 10. What is the signature !!! Procedure Procedure name( Var Variable Name : Type );Var Variable Name : Type
  • 11. What is the prototype {define} !!!
  • 12. What is the prototype !!! Procedure Procedure name( Var Variable Name : Type );
  • 13. Program Lesson1_Program1 (input,output); Var Z :integer ; Procedure Square(X : Integer; Var y : Integer); var moxo :real ; Begin ………… End; Begin …………. End.
  • 14. Program Lesson1_Program1 (input,output); Var Z :integer ; Procedure Square(X : Integer ; Var y : Integer); var moxo :real ; Begin ………… End; Begin …………. End. When you declare parameters to a procedure, variables must separated by a semi-colon ";".They are put in between the brackets, following the procedure name.
  • 15. Program Lesson1_Program1 (input,output); Var X , Z : integer ; Procedure Square(R : Integer ; Var Result : Integer); Begin Result := R * R ; End; Begin Readln(X); Square(X,Z); Writeln('The square of X is: '); Writeln( Z ); End.
  • 16. Program Lesson1_Program1 (input,output); Var X , Z : integer ; Procedure Square(R : Integer); Var Result : Integer; Begin Result := R * R ; writeln ('The square of X is: ' , Result); End; Begin Readln(X); Square(X); End.
  • 17. •Let’sTalk a little bit a bout our built in function !!
  • 18. • ABS( -5 ) 5 • Chr( 97 ) a • Ord( ‘ a ’ ) 97 • Sin(x) Cos(x) • Pred( 6 ) 5 • Sqr( 3 ) 9 • Sqrt( 9 ) 3 • Odd( 3 ) True • Even( 3 ) False • Succ ( 5 ) 6
  • 19. • Round( 3.14 ) 3 • Round( 3.64 ) 4
  • 20. •FunctionareThe second type of sub-program . • The only difference from the procedure is that the Function return a value at the end. • A Function start off with a begin and ends up with an end;. • It can also have its own variables, which cannot be used with the main-program. Function FunctionName(Var VariableName:Type): Return Type;
  • 21. Program Lesson1_Program1 (input,output); Var Function Square(X : Integer): Integer ; var Begin ………… End; Begin …………. End.
  • 22. Program Lesson1_Program1 (input,output); Var X , Z : integer ; Function Square(R : Integer) : Integer; Begin Square := R * R ; End; Begin Readln(X); Z:= Square(X); Writeln('The square of X is: '); Writeln( Z ); End.