Pascal Programming Written by Leung King Yung. Simple Program 1 begin end.

Slides:



Advertisements
Similar presentations
MAIN BODY OF PROGRAM DECLARATION ACTION
Advertisements

Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Pascal Programming Today Chapter 4 1 »Conditional statements allow the execution of one of a number of possible operations. »Conditional statements include:
Program CheckPass; var TestScore, ExamScore : integer; FinalScore : real; Status : string; begin write(‘Enter the Test score:’); readln(Testscore); write(‘Enter.
James Tam Repetition In Pascal In this section of notes you will learn how to have a section of code repeated without duplicating the code.
James Tam Repetition In Pascal In this section of notes you will learn how to rerun parts of your program without having to duplicate the code.
James Tam Loops In Pascal In this section of notes you will learn how to rerun parts of your program without having to duplicate your code.
A simple C++ program /* * This program prints the phrase "Hello world!" * on the screen */ #include using namespace std; int main () { cout
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
Javascript II Expressions and Data Types. 2 JavaScript Review programs executed by the web browser programs embedded in a web page using the script element.
Mini-Pascal Compiling Mini-Pascal (MPC) language
Pascal By: Liane Tom. Outline o Background o Data types and Syntax o Procedures and Functions o Advantages o Disadvantages.
CS241 PASCAL I - Control Structures1 PASCAL I - Control Structures Philip Fees CS241.
1 Lecture 5  More flow control structures  for  do  continue  break  switch  Structured programming  Common programming errors and tips  Readings:
FOR DOWNTO Suppose you want to write a FOR-DO loop where the control variable is decreased with each repetition of the loop. Pascal provides the reserved.
The Data Element. 2 Data type: A description of the set of values and the basic set of operations that can be applied to values of the type. Strong typing:
Pascal Course Spring Introduction Designed: 1968/9 by Niklaus Wirth Published: 1970 Imperative, structural, procedural Static and strong.
1 The CONST definition CONST Pi = , City = ‘New York’; Constant identifiers are used when you do not want the value of an identifier to change why.
2440: 211 Interactive Web Programming Expressions & Operators.
Pascal language Slides of Omar Al-Nahal. Components of Pascal Language Components of Pascal Language 1. Pascal Character set: - English Letters. - Decimal.
Selection Boolean What is Boolean ? Boolean is a set with only two values : –true –false true and false are standard identifiers in Pascal, called Boolean.
CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal.
Introduction to Pascal The Basics of Program writing.
CONTENTS Processing structures and commands Control structures – Sequence Sequence – Selection Selection – Iteration Iteration Naming conventions – File.
Programming, an introduction to Pascal
Pascal Course Spring Introduction Designed: 1968/9 by Niklaus Wirth Published: 1970 Imperative, structural, procedural Static and strong.
1 homework Due today: hw #1 (mailing list printout) readings to date: chapter 1 and chapter read appendix B (3 pages on DOS) and and.
CSC1201: Programming Language 2 Lecture 1 Level 2 Course Nouf Aljaffan (C) CSC 1201 Course at KSU1.
C++ Basics. Compilation What does compilation do? g++ hello.cpp g++ -o hello.cpp hello.
Pascal Programming Arrays and String Type.
Pascal Programming Iteration (looping) Carl Smith National Certificate Unit 4.
PSU CS 106 Computing Fundamentals II VB Declarations HM 5/4/2008.
Pascal Programming Pascal Loops and Debugging. Pascal Programming Pascal Loops In our first brush with the while do loops, simple comparisons were used.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
CS241 PASCAL I - Control Structures1 PASCAL Control Structures Modified Slides of Philip Fees.
Higher Computing Software Development -So Far- 5/10/10.
DATA TYPES, VARIABLES AND CONSTANTS. LEARNING OBJECTIVES  Be able to identify and explain the difference between data and information  Be able to identify,
Scion Macros How to make macros for Scion The Fast and Easy Guide.
5-3(D) Real Numbers.
Pascal Programming George Boole, a 19 th Century mathematician, is created with true, false logic. A Boolean expression in Pascal will be true or false.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
Topics for today: 1.Comments 2.Data types 3.Variable declaration.
Midterm preview.
Basic concepts of C++ Presented by Prof. Satyajit De
Definition of the Programming Language CPRL
Written by Al.So. Software solutions
Visual Basic 6 (VB6) Data Types, And Operators
Introduction to Computer Science / Procedural – 67130
Documentation Need to have documentation in all programs
CPSC Pascal Brent M. Dingle Texas A&M University 2001, 2002
Starter Question In your jotter write the pseudocode to take in two numbers, add them together then display the answer. Declare variables RECEIVE firstNumber.
A Very Brief Overview of Pascal
البرمجة بلغة الفيجول بيسك ستوديو
البرمجة بلغة فيجول بيسك ستوديو
Introduction to C++ Programming
An overview of Java, Data types and variables
kbkjlj/m/lkiubljj'pl;
Do … Loop Until (condition is true)
Recap Week 2 and 3.
Language Constructs Construct means to build or put together. Language constructs refers to those parts which make up a high level programming language.
Chapter 2 Programming Basics.
2. Second Step for Learning C++ Programming • Data Type • Char • Float
Intro to Programming Concepts
The Data Element.
C# Revision Cards Data types
The Data Element.
Millennium High School Agenda Calendar
Python 4 and 5 Mr. Husch.
COMPUTING.
Presentation transcript:

Pascal Programming Written by Leung King Yung

Simple Program 1 begin end.

Simple Program 2 program Test; uses wincrt; begin writeln(‘Good Afternoon!’); end.

Simple Program 2 Results:

Reserverd Words begin end program var string if then else for to downto while do repeat until procedure function in These are the common reserved words of pascal program. You cannot use this as a variable name.

Program Title program Test; {This is the program title(you can omit it)} begin {Main Body} end.

Data type These are the common data type of pascal program. TypeExplanation Additional explanation Example integer Whole numbers 3, 104, 0, -9 string String variable(Text) 'Hello World', '456,4' char Character(One character) 'b', 'A', '7' boolean Boolean variable Can only be True or False True, False real Real numbers(Floating point numbers) 4.0, -0.08, 48.6, 2.0E4

Declaring variable program Test; var i : integer; var s : string; var c : char; var b : boolean; var r : real; begin {Main Body} end.

Declaring variable program Test; Uses wincrt; var i : integer; s : string; c : char; b : boolean; r : real; Begin I := 0; Writeln(i); end.

Using Library program Test; uses wincrt; {Wincrt is a common library in turbo pascal for i/o manipulations wincrt.tpu} var i : integer; begin {Main Body} end.

Using Variables program Test; uses wincrt; var i : integer; Begin Readln(i); writeln(i); end.

Using Variables Results:

Using Variables program Test; uses wincrt; var i : integer; j : integer; begin i := 7; j := 3; i := i + j; writeln(i); end.

Using Variables Results:

Comparing VB with Pascal VB: Dim i as integer Pascal: var i : integer; VB: i = 10 Pascal: i := 10; VB: ‘comment Pascal: {Comment}/(*Comment*)

Comparing VB with Pascal VB: Dim j as integer j = 10 If j = 10 then print “J = 10” Else print “J <> 10” End If

Comparing VB with Pascal Pascal: Uses wincrt; var j : integer; begin j := 10; if j = 10 then writeln(‘J = 10’) else writeln(‘J <> 10’); End.

IF…THEN…ELSE program Test; var j : integer; begin j := 10; if j = 10 then writeln(‘J = 10’) {*** No “;”} else writeln(‘J <> 10’); writeln(‘End of program’); end;

IF…THEN…ELSE program Test; var j : integer; begin j := 10; if j = 10 then writeln(‘J = 10’) else writeln(‘J <> 10’); writeln(‘End of program’); end; The whole If-Phrase

Complicated IF…THEN…ELSE if i = 10 then if j = 10 then writeln(‘i = 10 and j = 10’) else writeln(‘i = 10 and j <> 10’) else writeln(‘i <> 10 and j <> 10’); Correct Program

Complicated IF…THEN…ELSE if i = 10 then if j = 10 then writeln(‘i = 10 and j = 10’) else writeln(‘i = 10 and j <> 10’); else writeln(‘i <> 10 and j <> 10’); Wrong semicolon (Syntax Error)

Comment begin {This is a comment} (* This is also a comment*) end.