SlideShare a Scribd company logo
1 of 53
Write programs to solve problems
Pascal Programming
1
By Anutthara Senanayake
Lecturer
Sri Lanka International Buddhist Academy
IT Department @ SIBA Campus
Session 01
A problem
Input, Output and Process
Alternative solutions
Algorithm
Control Structures in Algorithms
To display Algorithms : Flowcharts & Pseudocodes
Pascal Programming
Why Pascal is more popular ?
Turbo Pascal
Identifiers
Reserved Words
Data Types
Variables
Constants
Program Structure
Control Structures
2
IT Department @ SIBA Campus
A Problem
3
IT Department @ SIBA Campus
Problem 01
4
IT Department @ SIBA Campus
Input , Output & Process
5
IT Department @ SIBA Campus
Algorithms
Definition
An algorithm is a
procedure or
formula for solving
a problem.
6
IT Department @ SIBA Campus
Control Structures in Algorithms
Sequence
Selection
Iteration
7
IT Department @ SIBA Campus
To display Algorithms : Flowcharts &
Pseudocodes
8
IT Department @ SIBA Campus
Pascal Programming
9
Pascal is a general-purpose, high-level
language that was originally developed by
Niklaus Wirth in the early 1970s.
It was developed for teaching programming
as a systematic discipline and to develop
reliable and efficient programs.
IT Department @ SIBA Campus
Why Pascal is more popular ?
Easy to learn.
Structured language.
It produces transparent, efficient and reliable programs.
It can be compiled on a variety of computer platforms.
10
IT Department @ SIBA Campus
Turbo Pascal
11
IT Department @ SIBA Campus
Additional Notes
How to run turbo Pascal in Dos Box - Type following commands
Mount c C:TP
C:
Cd BIN
turbo.exe
12
IT Department @ SIBA Campus
Identifiers
Identifiers are names that allow you to reference stored
values, such as variables and constants.
13
IT Department @ SIBA Campus
Exercise 01
Select the valid identifiers from the given list.
1. Myname
2. @me2
3. me2
4. saman
5. my-add
6. my_add
7. $sea_u 14
IT Department @ SIBA Campus
Reserved Words
program, input, output, var, real, begin, readline, writeline , end
15
IT Department @ SIBA Campus
Data Types
16
IT Department @ SIBA Campus
Variables
17
var myname : string
IT Department @ SIBA Campus
Constants
A const is a keyword
applied to a data type
that indicates that the
data is constant (does
not vary).
18
Const pi=22/7;
IT Department @ SIBA Campus
Operators
19
Arithmetic Operators
Relational Operators
Logical Operators
IT Department @ SIBA Campus
Program Structure
20
Program Name
Library
Main program starting
point
Main program ending
point
Output
IT Department @ SIBA Campus
Exercise 02
Write a Pascal program to calculate the sum of two integer
numbers.
21
IT Department @ SIBA Campus
Control Structures - IF…THEN…ENDIF
Exercise 03
Write a Pascal program to print the entered, number if it is
only a positive number.
22
IT Department @ SIBA Campus
Exercise 04
Write a Pascal program to print “Pass” if the mark is greater
than 50.
23
IT Department @ SIBA Campus
Control Structures - IF….THEN….ELSE…..ENDIF
Exercise 05
Write a Pascal program to find the maximum number out of
two given numbers.
24
IT Department @ SIBA Campus
Control Structures -Nested IF
Exercise 07
Write a Pascal program to print the correct grade for the
given mark. (mark >= 75 =>A, mark >=65=> B, mark >=50 =>C,
mark =>35=>S, else F)
25
IT Department @ SIBA Campus
Exercise 08
Write a Pascal program to display the day of the week when
the day number is provided.
26
IT Department @ SIBA Campus
Control Structures - CASE statements
Exercise 09
Write a Pascal program to print the grade according to the
criteria for the given mark.
0-34 => F , 35 – 49 =>S , 50 – 64 =>C, 65 – 74 => B, 75 – 100
=>A
27
IT Department @ SIBA Campus
Control Structures - FOR - DO
Exercise 10
Write a Pascal program to print numbers starting from 10 to
1.
28
IT Department @ SIBA Campus
Exercise 11
Write a Pascal program to calculate the sum and the average
of given 10 numbers.
29
IT Department @ SIBA Campus
Control Structures -WHILE DO
Exercise 12
Develop a computer based solution to receive a set of
positive numbers or 0 from user and display the total value.
Data input will stop when a negative value is entered.
30
IT Department @ SIBA Campus
Control Structures - REPEAT UNTIL
Exercise 13
Write a Pascal program to print the word “Pascal” 5 times.
31
IT Department @ SIBA Campus
Control Structures - Nested Control Structures
Exercise 14
Write a Pascal program to make a number series according
to the ascending or descending order
32
IT Department @ SIBA Campus
Exercise 15
Write a Pascal program to input numbers and calculate the
count of odd numbers and the count of even numbers.
33
IT Department @ SIBA Campus
Lets do some more on Pascal
34
IT Department @ SIBA Campus
Session 02
Arrays
Declaring Arrays
Assigning Values
Accessing Values
Sub Programs
Functions
Defining a Function
Function Declarations
Calling a Functions
Procedures
Defining a Procedure
Procedure Declarations
Calling a Procedure
35
IT Department @ SIBA Campus
Arrays
An array is a highly useful
data structure that stores
variable data having
the same data type
36
IT Department @ SIBA Campus
37
An array is said to be a static data structure because, once declared, its original
size that is specified by the programmer will remain the same throughout the
whole program and cannot be changed.
IT Department @ SIBA Campus
Declaring Arrays
Syntax
Var
<arrayName> : Array[n..m] of <Data Type>;
38
IT Department @ SIBA Campus
Assigning Values
Syntax
<arrayName>[index] := <relevant data>
39
IT Department @ SIBA Campus
Accessing Values
By using a for loop we can easily access the array
40
IT Department @ SIBA Campus
Exercise 01
Write a Pascal program to find the sum of a given integer array.
41
IT Department @ SIBA Campus
Sub Programs
• A subprogram is a program unit/module that performs a particular task.
• These subprograms are combined to form larger programs.
42
IT Department @ SIBA Campus
Pascal provides two kinds of subprograms:
Functions: these subprograms return a single value.
Procedures: these subprograms do not return a value
directly.
43
IT Department @ SIBA Campus
44
IT Department @ SIBA Campus
Functions
A function is a group of statements that together perform a task.
45
IT Department @ SIBA Campus
46
IT Department @ SIBA Campus
Function Declarations
47
Calling a Functions
IT Department @ SIBA Campus
48
IT Department @ SIBA Campus
Procedures
Procedures are subprograms that, instead of returning a single value,
allow to obtain a group of results.
49
IT Department @ SIBA Campus
50
IT Department @ SIBA Campus
Procedure Declarations
51
Calling a Procedure
IT Department @ SIBA Campus
52
Thank you !
53

More Related Content

What's hot

Pascal Programming Language
Pascal Programming LanguagePascal Programming Language
Pascal Programming LanguageReham AlBlehid
 
String matching with finite state automata
String matching with finite state automataString matching with finite state automata
String matching with finite state automataAnmol Hamid
 
Introduction to Pseudocode
Introduction to PseudocodeIntroduction to Pseudocode
Introduction to PseudocodeDamian T. Gordon
 
Complete C++ programming Language Course
Complete C++ programming Language CourseComplete C++ programming Language Course
Complete C++ programming Language CourseVivek chan
 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language Mohamed Loey
 
BASIC Programming Language
BASIC Programming LanguageBASIC Programming Language
BASIC Programming LanguageJeff Valerio
 
Theory of programming
Theory of programmingTheory of programming
Theory of programmingtcc_joemarie
 
Distributed Hash Table
Distributed Hash TableDistributed Hash Table
Distributed Hash TableAmir Payberah
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT03062679929
 
Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C BUBT
 
Access specifiers (Public Private Protected) C++
Access specifiers (Public Private  Protected) C++Access specifiers (Public Private  Protected) C++
Access specifiers (Public Private Protected) C++vivekkumar2938
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchartSachin Goyani
 

What's hot (20)

C++ programs
C++ programsC++ programs
C++ programs
 
Pascal Programming Language
Pascal Programming LanguagePascal Programming Language
Pascal Programming Language
 
Kruskal Algorithm
Kruskal AlgorithmKruskal Algorithm
Kruskal Algorithm
 
SQL select clause
SQL select clauseSQL select clause
SQL select clause
 
Operators in java
Operators in javaOperators in java
Operators in java
 
String matching with finite state automata
String matching with finite state automataString matching with finite state automata
String matching with finite state automata
 
Introduction to Pseudocode
Introduction to PseudocodeIntroduction to Pseudocode
Introduction to Pseudocode
 
Php and MySQL
Php and MySQLPhp and MySQL
Php and MySQL
 
Complete C++ programming Language Course
Complete C++ programming Language CourseComplete C++ programming Language Course
Complete C++ programming Language Course
 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language
 
BASIC Programming Language
BASIC Programming LanguageBASIC Programming Language
BASIC Programming Language
 
Theory of programming
Theory of programmingTheory of programming
Theory of programming
 
Bubble in link list
Bubble in link listBubble in link list
Bubble in link list
 
Distributed Hash Table
Distributed Hash TableDistributed Hash Table
Distributed Hash Table
 
Database constraints
Database constraintsDatabase constraints
Database constraints
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
 
Control structure in c
Control structure in cControl structure in c
Control structure in c
 
Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C
 
Access specifiers (Public Private Protected) C++
Access specifiers (Public Private  Protected) C++Access specifiers (Public Private  Protected) C++
Access specifiers (Public Private Protected) C++
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 

Similar to Pascal Programming Guide for Solving Problems

Sample Questions The following sample questions are not in.docx
Sample Questions The following sample questions are not in.docxSample Questions The following sample questions are not in.docx
Sample Questions The following sample questions are not in.docxtodd331
 
best notes in c language
best notes in c languagebest notes in c language
best notes in c languageIndia
 
Introduction to matlab lecture 1 of 4
Introduction to matlab lecture 1 of 4Introduction to matlab lecture 1 of 4
Introduction to matlab lecture 1 of 4Randa Elanwar
 
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptLecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptReshuReshma8
 
66781291 java-lab-manual
66781291 java-lab-manual66781291 java-lab-manual
66781291 java-lab-manualLaura Popovici
 
program development and paradigms
program development and paradigmsprogram development and paradigms
program development and paradigmskasenerd
 
MATLAB Programs For Beginners. | Abhi Sharma
MATLAB Programs For Beginners. | Abhi SharmaMATLAB Programs For Beginners. | Abhi Sharma
MATLAB Programs For Beginners. | Abhi SharmaAbee Sharma
 
Basic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and FlowchartsBasic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and Flowchartsmoazwinner
 
Problem Solving Techniques and Introduction to C
Problem Solving Techniques and Introduction to CProblem Solving Techniques and Introduction to C
Problem Solving Techniques and Introduction to CPrabu U
 
Problem-solving and design 1.pptx
Problem-solving and design 1.pptxProblem-solving and design 1.pptx
Problem-solving and design 1.pptxTadiwaMawere
 
Data Structures- Part1 overview and review
Data Structures- Part1 overview and reviewData Structures- Part1 overview and review
Data Structures- Part1 overview and reviewAbdullah Al-hazmy
 
Python Programming - II. The Basics
Python Programming - II. The BasicsPython Programming - II. The Basics
Python Programming - II. The BasicsRanel Padon
 

Similar to Pascal Programming Guide for Solving Problems (20)

Cse
CseCse
Cse
 
Simulation lab
Simulation labSimulation lab
Simulation lab
 
maple project.pptx
maple project.pptxmaple project.pptx
maple project.pptx
 
Sample Questions The following sample questions are not in.docx
Sample Questions The following sample questions are not in.docxSample Questions The following sample questions are not in.docx
Sample Questions The following sample questions are not in.docx
 
GE3171-PROBLEM SOLVING AND PYTHON PROGRAMMING LABORATORY
GE3171-PROBLEM SOLVING AND PYTHON PROGRAMMING LABORATORYGE3171-PROBLEM SOLVING AND PYTHON PROGRAMMING LABORATORY
GE3171-PROBLEM SOLVING AND PYTHON PROGRAMMING LABORATORY
 
best notes in c language
best notes in c languagebest notes in c language
best notes in c language
 
Introduction to matlab lecture 1 of 4
Introduction to matlab lecture 1 of 4Introduction to matlab lecture 1 of 4
Introduction to matlab lecture 1 of 4
 
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptLecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
 
66781291 java-lab-manual
66781291 java-lab-manual66781291 java-lab-manual
66781291 java-lab-manual
 
program development and paradigms
program development and paradigmsprogram development and paradigms
program development and paradigms
 
MATLAB Programs For Beginners. | Abhi Sharma
MATLAB Programs For Beginners. | Abhi SharmaMATLAB Programs For Beginners. | Abhi Sharma
MATLAB Programs For Beginners. | Abhi Sharma
 
Basic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and FlowchartsBasic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and Flowcharts
 
C++ Lab Maual.pdf
C++ Lab Maual.pdfC++ Lab Maual.pdf
C++ Lab Maual.pdf
 
C++ Lab Maual.pdf
C++ Lab Maual.pdfC++ Lab Maual.pdf
C++ Lab Maual.pdf
 
Problem Solving Techniques and Introduction to C
Problem Solving Techniques and Introduction to CProblem Solving Techniques and Introduction to C
Problem Solving Techniques and Introduction to C
 
MATLAB INTRODUCTION
MATLAB INTRODUCTIONMATLAB INTRODUCTION
MATLAB INTRODUCTION
 
Excel
ExcelExcel
Excel
 
Problem-solving and design 1.pptx
Problem-solving and design 1.pptxProblem-solving and design 1.pptx
Problem-solving and design 1.pptx
 
Data Structures- Part1 overview and review
Data Structures- Part1 overview and reviewData Structures- Part1 overview and review
Data Structures- Part1 overview and review
 
Python Programming - II. The Basics
Python Programming - II. The BasicsPython Programming - II. The Basics
Python Programming - II. The Basics
 

Recently uploaded

Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 

Recently uploaded (20)

Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 

Pascal Programming Guide for Solving Problems

  • 1. Write programs to solve problems Pascal Programming 1 By Anutthara Senanayake Lecturer Sri Lanka International Buddhist Academy
  • 2. IT Department @ SIBA Campus Session 01 A problem Input, Output and Process Alternative solutions Algorithm Control Structures in Algorithms To display Algorithms : Flowcharts & Pseudocodes Pascal Programming Why Pascal is more popular ? Turbo Pascal Identifiers Reserved Words Data Types Variables Constants Program Structure Control Structures 2
  • 3. IT Department @ SIBA Campus A Problem 3
  • 4. IT Department @ SIBA Campus Problem 01 4
  • 5. IT Department @ SIBA Campus Input , Output & Process 5
  • 6. IT Department @ SIBA Campus Algorithms Definition An algorithm is a procedure or formula for solving a problem. 6
  • 7. IT Department @ SIBA Campus Control Structures in Algorithms Sequence Selection Iteration 7
  • 8. IT Department @ SIBA Campus To display Algorithms : Flowcharts & Pseudocodes 8
  • 9. IT Department @ SIBA Campus Pascal Programming 9 Pascal is a general-purpose, high-level language that was originally developed by Niklaus Wirth in the early 1970s. It was developed for teaching programming as a systematic discipline and to develop reliable and efficient programs.
  • 10. IT Department @ SIBA Campus Why Pascal is more popular ? Easy to learn. Structured language. It produces transparent, efficient and reliable programs. It can be compiled on a variety of computer platforms. 10
  • 11. IT Department @ SIBA Campus Turbo Pascal 11
  • 12. IT Department @ SIBA Campus Additional Notes How to run turbo Pascal in Dos Box - Type following commands Mount c C:TP C: Cd BIN turbo.exe 12
  • 13. IT Department @ SIBA Campus Identifiers Identifiers are names that allow you to reference stored values, such as variables and constants. 13
  • 14. IT Department @ SIBA Campus Exercise 01 Select the valid identifiers from the given list. 1. Myname 2. @me2 3. me2 4. saman 5. my-add 6. my_add 7. $sea_u 14
  • 15. IT Department @ SIBA Campus Reserved Words program, input, output, var, real, begin, readline, writeline , end 15
  • 16. IT Department @ SIBA Campus Data Types 16
  • 17. IT Department @ SIBA Campus Variables 17 var myname : string
  • 18. IT Department @ SIBA Campus Constants A const is a keyword applied to a data type that indicates that the data is constant (does not vary). 18 Const pi=22/7;
  • 19. IT Department @ SIBA Campus Operators 19 Arithmetic Operators Relational Operators Logical Operators
  • 20. IT Department @ SIBA Campus Program Structure 20 Program Name Library Main program starting point Main program ending point Output
  • 21. IT Department @ SIBA Campus Exercise 02 Write a Pascal program to calculate the sum of two integer numbers. 21
  • 22. IT Department @ SIBA Campus Control Structures - IF…THEN…ENDIF Exercise 03 Write a Pascal program to print the entered, number if it is only a positive number. 22
  • 23. IT Department @ SIBA Campus Exercise 04 Write a Pascal program to print “Pass” if the mark is greater than 50. 23
  • 24. IT Department @ SIBA Campus Control Structures - IF….THEN….ELSE…..ENDIF Exercise 05 Write a Pascal program to find the maximum number out of two given numbers. 24
  • 25. IT Department @ SIBA Campus Control Structures -Nested IF Exercise 07 Write a Pascal program to print the correct grade for the given mark. (mark >= 75 =>A, mark >=65=> B, mark >=50 =>C, mark =>35=>S, else F) 25
  • 26. IT Department @ SIBA Campus Exercise 08 Write a Pascal program to display the day of the week when the day number is provided. 26
  • 27. IT Department @ SIBA Campus Control Structures - CASE statements Exercise 09 Write a Pascal program to print the grade according to the criteria for the given mark. 0-34 => F , 35 – 49 =>S , 50 – 64 =>C, 65 – 74 => B, 75 – 100 =>A 27
  • 28. IT Department @ SIBA Campus Control Structures - FOR - DO Exercise 10 Write a Pascal program to print numbers starting from 10 to 1. 28
  • 29. IT Department @ SIBA Campus Exercise 11 Write a Pascal program to calculate the sum and the average of given 10 numbers. 29
  • 30. IT Department @ SIBA Campus Control Structures -WHILE DO Exercise 12 Develop a computer based solution to receive a set of positive numbers or 0 from user and display the total value. Data input will stop when a negative value is entered. 30
  • 31. IT Department @ SIBA Campus Control Structures - REPEAT UNTIL Exercise 13 Write a Pascal program to print the word “Pascal” 5 times. 31
  • 32. IT Department @ SIBA Campus Control Structures - Nested Control Structures Exercise 14 Write a Pascal program to make a number series according to the ascending or descending order 32
  • 33. IT Department @ SIBA Campus Exercise 15 Write a Pascal program to input numbers and calculate the count of odd numbers and the count of even numbers. 33
  • 34. IT Department @ SIBA Campus Lets do some more on Pascal 34
  • 35. IT Department @ SIBA Campus Session 02 Arrays Declaring Arrays Assigning Values Accessing Values Sub Programs Functions Defining a Function Function Declarations Calling a Functions Procedures Defining a Procedure Procedure Declarations Calling a Procedure 35
  • 36. IT Department @ SIBA Campus Arrays An array is a highly useful data structure that stores variable data having the same data type 36
  • 37. IT Department @ SIBA Campus 37 An array is said to be a static data structure because, once declared, its original size that is specified by the programmer will remain the same throughout the whole program and cannot be changed.
  • 38. IT Department @ SIBA Campus Declaring Arrays Syntax Var <arrayName> : Array[n..m] of <Data Type>; 38
  • 39. IT Department @ SIBA Campus Assigning Values Syntax <arrayName>[index] := <relevant data> 39
  • 40. IT Department @ SIBA Campus Accessing Values By using a for loop we can easily access the array 40
  • 41. IT Department @ SIBA Campus Exercise 01 Write a Pascal program to find the sum of a given integer array. 41
  • 42. IT Department @ SIBA Campus Sub Programs • A subprogram is a program unit/module that performs a particular task. • These subprograms are combined to form larger programs. 42
  • 43. IT Department @ SIBA Campus Pascal provides two kinds of subprograms: Functions: these subprograms return a single value. Procedures: these subprograms do not return a value directly. 43
  • 44. IT Department @ SIBA Campus 44
  • 45. IT Department @ SIBA Campus Functions A function is a group of statements that together perform a task. 45
  • 46. IT Department @ SIBA Campus 46
  • 47. IT Department @ SIBA Campus Function Declarations 47 Calling a Functions
  • 48. IT Department @ SIBA Campus 48
  • 49. IT Department @ SIBA Campus Procedures Procedures are subprograms that, instead of returning a single value, allow to obtain a group of results. 49
  • 50. IT Department @ SIBA Campus 50
  • 51. IT Department @ SIBA Campus Procedure Declarations 51 Calling a Procedure
  • 52. IT Department @ SIBA Campus 52

Editor's Notes

  1. Graphical representation of an Algo
  2. Narrative representation