Introduction to Pascal The Basics of Program writing.

Slides:



Advertisements
Similar presentations
1 Programming in Pascal Presented by:- Zonal ICT Section- Kurunegala Education Zone.
Advertisements

Program CheckPass; var TestScore, ExamScore : integer; FinalScore : real; Status : string; begin write(‘Enter the Test score:’); readln(Testscore); write(‘Enter.
James Tam Getting Started With Pascal Programming How are computer programs created What is the basic structure of a Pascal Program Variables in Pascal.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 3, Lecture 2.
1 9/10/07CS150 Introduction to Computer Science 1 Data Types Section 2.7 – 2.12 CS 150 Introduction to Computer Science I.
C Programming Language 4 Developed in 1972 by Dennis Ritchie at AT&T Bell Laboratories 4 Used to rewrite the UNIX operating system 4 Widely used on UNIX.
James Tam Getting Started With Pascal Programming What is the basic structure of a Pascal Program Variables in Pascal Performing input and output with.
10 November JavaScript. Presentation Hints What do YOU think makes a good presentation Some of my suggestions Don’t write full sentences on slides Talk,
J. Michael Moore Input and Output (IO) CSCE 110 Drawn from James Tam's material.
Getting Started With Pascal Programming
1 Key Concepts:  Data types in C.  What is a variable?  Variable Declaration  Variable Initialization  Printf()  Scanf()  Working with numbers in.
Overview of C++ Chapter 2 in both books programs from books keycode for lab: get Program 1 from web test files.
Input and Output (IO) CSCE 110 Drawn from James Tam's material.
1 Lab Session-III CSIT-120 Spring 2001 Revising Previous session Data input and output While loop Exercise Limits and Bounds GOTO SLIDE 13 Lab session.
Introduction To C++ Programming 1.0 Basic C++ Program Structure 2.0 Program Control 3.0 Array And Structures 4.0 Function 5.0 Pointer 6.0 Secure Programming.
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
A Variable is symbolic name that can be given different values. Variables are stored in particular places in the computer ‘s memory. When a variable is.
Introduction to Python
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.
INTRODUCTION TO ALGORITHMS PROGRAMMING. Objectives Give a definition of the term algorithm Describe the various parts of the pseudocode algorithm or algorithm.
Pascal Programming Strings, Arithmetic operators and output formatting National Certificate – Unit 4 Carl Smith.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Copyright 1999 by Larry Fuhrer. Pascal Programming Getting Started...
VARIABLES & CONSTANTS. Objective By the end of the lesson students should be able to:  Define a constant  Define a variable  Understand the rules for.
Chapter 2: Using Data.
CSC 107 – Programming For Science. Announcements  Memorization is not important, but…  … you will all still be responsible for information  Instead.
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Pascal language Slides of Omar Al-Nahal. Components of Pascal Language Components of Pascal Language 1. Pascal Character set: - English Letters. - Decimal.
INFORMATION TECHNOLOGY CSEC CXC 10/25/ PASCAL is a programming language named after the 17th century mathematician Blaise Pascal. Pascal provides.
Lecture 2: Introduction to C Programming. OBJECTIVES In this lecture you will learn:  To use simple input and output statements.  The fundamental data.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 5, Lecture 1 (Monday)
Programming, an introduction to Pascal
1 st semester Basic Pascal Elements อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
Variables in Java x = 3;. What is a variable?  A variable is a placeholder in memory used by programmers to store information for a certain amount of.
VARIABLES AND DATA TYPES Chapter2:part1 1. Objectives: By the end of this section you should: Understand what the variables are and why they are used.
CSCI 3133 Programming with C Instructor: Bindra Shrestha University of Houston – Clear Lake.
Repetition. Loops Allows the same set of instructions to be used over and over again Starts with the keyword loop and ends with end loop. This will create.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 10.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 2A Reading, Processing and Displaying Data (Concepts)
1 More data types Character and String –Non-numeric variables –Examples: char orange; String something; –orange and something are variable names –Note.
PASCAL PROGRAMMING.
Creating PHP Pages Chapter 6 PHP Variables, Constants and Operators.
So now we’re programming What do programs do? Manipulate (process) data Math Read files Write to files Create files.
1 09/03/04CS150 Introduction to Computer Science 1 What Data Do We Have.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 5, Lecture 2 (Tuesday)
Variables in VB. What is a variable? ► A named memory location that stores a value.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
1 st Semester Module2 Basic C# Concept อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
LESSON 2 Basic of C++.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
FOR LOOP STRUCTURE For := to do eg. for I := 1 to 100 do begin writeln(‘This is a loop’); end;
Pascal Programming Today Chapter 2 1 Chapter 2. Pascal Programming Today Chapter 2 2 »Output statements write data to output devices (e.g. VDU). »Two.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Chapter 2 – part b Brent M. Dingle Texas A&M University
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
LESSON 2 Basic of C++.
Introduction to C++ Programming
kbkjlj/m/lkiubljj'pl;
Computer Science 1 Get out your notebook
C# Revision Cards Data types
Computer Science 1 Get out your notebook
Computer Science 1 Get out your notebook
DATA TYPES AND OPERATIONS
Variables and Constants
Getting Started With Coding
Presentation transcript:

Introduction to Pascal The Basics of Program writing.

Pascal Format Program ; const ; var begin end. HEADER VARIABLE DECLARATION PROGRAM BODY CONSTANT DECLARATION

Constants and Variables Identifier – The name that identifies a variable or constant Constant – a value that is stored in memory and cannot be changed. Eg. Pi = 3.14 Variable – A value that is stored in memory and can be changed. Eg. x,a,b,y…….

Variable Types Integer – positive and negative numbers which do not have a decimal point. Real – positive and negative numbers that my have a decimal point Char – a single character (letter, digit or symbol) String – a group of characters Boolean – either true or false

Declaring Variables var gender: char; num1, num2, num3: integer; product: real THREE VARIABLES OF THE SAME TYPE CAN BE SEPARATED BY A COMMA

Declaring Constants const pi = 3.142; VAT = 0.15; Gravity = 9.81;

Basic Commands Write – writes the command on the same line Writeln – writes the command and goes to the next line Read – reads the input Realn – reads the input and then goes to the next line.

Write commands Write(‘ hello world’); Writeln (‘hello world’); Hello World DISPLAYS ‘HELLO WORLD’ IN THE SAME LINE Hello World _ DISPLAYS ‘HELLO WORLD’ AND GOES TO THE NEXT LINE

Read Commands Read(num1) This will read the input from the user of the program and store the value in num1 Readln(num1) This will read the input from the user and store the value in num1 and go to the next line. It is also used to pause at the end of a program until the user presses enter.

Assignments The value of a variable can be changed by doing an assignment statement. It is done by using a colon and equal sign. := eg. Age := 15 cost := 65 Count := count + 1

Simple Progams Program HelloWorld; Begin Write(‘Hello World’); Readln; End. This program writes Hello World and then waits for the user to press enter to exit the program.

Simple Programs program Hello; begin Writeln('Hello'); Write('world'); Readln; end. This program writes ‘Hello’ in one line then goes to the other, then it prints ‘World’ and waits for the user to press enter.

Simple Programs Program Addition; Var a:integer; Begin Writeln('The sum of 6 and 4 is:'); a := 6 + 4; write(a); readln; End. This declares ‘a’ as an integer. It then adds two numbers and assigns the result to ‘a’.

Simple Programs Program Multiplication; Var a: integer; Begin Writeln ('This will find the product of 6 and 4'); a := 6*4 ; writeln ('Press enter to view the result'); readln; write(a); readln; End. This declares ‘a’ as an integer. It then multiplies two numbers and assigns the result to ‘a’. Then displays ‘a’

Simple Programs Program addition; Var a:integer; b:integer; c: integer; Begin writeln(‘Enter first number’); read(a); writeln(Enter second number’); read(b); writeln(‘Your numbers are: ‘,a,b); c:= a + b writeln(‘the sum of your numbers is:’); write(c); readln; End. This declares ‘a’ ‘b’ and ‘c’ as integers. It then adds ‘a’ to ‘b’ and assigns the result to ‘c’. Then displays ‘c’