Want to create interactive content? It’s easy in Genially!

Get started free

Pascal

Olga Ella

Created on April 5, 2022

Start designing with a free template

Discover more than 1500 professional designs like these:

Transcript

Introduction to programming

PASCAL_

Programming language ___

start_

Introduction to programming

DEFINITION

VARIABLES

Pascal FORMAT

Declaring Variables AND CONSTANTS

Basic Commands

Advantages and desadvantages

Simple Progams

Questions

Simple Progams

Introduction to programming

What is the Pascal programming language?

PASCAL is a programming language named after the 17th century mathematician Blaise Pascal. The Pascal programming language provides a teaching language that highlights concepts common to all computer languages. It standardizes the language in such a way that it makes programs easy to write.

info

Introduction to programming

Pascal FORMAT

Program <program name>; const <constant value in the program>; var <variables used in the program>; begin <the actual program code>; end.
HEADER
CONSTANT DECLARATION
VARIABLE DECLARATION
PROGRAM BODY

info

Introduction to programming

VARIABLES

A variable is an item that allows you to store data into it.Variable names are a maximum of 32 alphanumeric characters. Naming a variable : The 1st letter of the variable must be alphabetic (A to Z) or (a to z), followed by either letters, a number or an underscore eg. num, age2, avg, sum, first_num etc. Variable (Data) Types: Integer – to store integer or ‘whole’ numbers; Real – to store fractional numbers; Char - to store a single character such as a letter, digit or punctuation - A, b, 4, x, Y; String – to store a collection of characters; Boolean - used for values that are True/False or Yes/No type responses.

info

Introduction to programming

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;

info

Introduction to programming

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.

info

Introduction to programming

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.

info

Introduction to programming

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’.

info

Introduction to programming

advantages

- Each unit has it's own identifiers In Pascal you never need to worry about polluting the namespace, like in C where an identifier needs to be unique accross the entire program. No, in Pascal each unit gets it's own namespace; - High speed, low memory use. Pascal is one of the fastest languages there are. Further, Free Pascal programs use little memory; - Possible to work with complex data types;

disadvantage

- The popularity of this language declined in the 1980s and 1990s;- Problems whith control --- flow; "while (i <= XMAX) and (x[i] > o) do" - No break - statement; - No return - statement;

info

Introduction to programming

QUESTIONS

1.In honor of whose personality this programming language was named?

2.What is the general format of a Pascal program?

3.What are the types of variables?

4.What are the basic commands?

5.Who Developed the Pascal Programming Language?

info