0% found this document useful (0 votes)
117 views4 pages

Pascal Programming

The document provides examples of Pascal code to calculate the perimeter of different shapes like a rectangle and circle. It also includes pseudocode to find the average of three numbers entered by a user and the time required to travel a given distance at a specific speed. The code examples demonstrate how to declare and assign variables, take user input, perform calculations, and output results. Key aspects of the code like using 'begin' and 'end' to mark the body and 'read' and 'write' for input/output are also explained.

Uploaded by

Tayviah Marshall
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
117 views4 pages

Pascal Programming

The document provides examples of Pascal code to calculate the perimeter of different shapes like a rectangle and circle. It also includes pseudocode to find the average of three numbers entered by a user and the time required to travel a given distance at a specific speed. The code examples demonstrate how to declare and assign variables, take user input, perform calculations, and output results. Key aspects of the code like using 'begin' and 'end' to mark the body and 'read' and 'write' for input/output are also explained.

Uploaded by

Tayviah Marshall
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Information Technology

January 9th, 2023


Topic: Programming

Write a program in Pascals to calculate the perimeter of a rectangle.

Pseudocode
Input – Read Length, Width
Processing – Perimeter  Length + Width + Length + Wide
Output – Display Perimeter

Pascal
Program Perimeter_of_Rectangle (input, output)
Var Length, width, perimeter: integer;
Begin
Writeln (‘Please enter a value for length and width’);
Readln (Length, width);
Perimeter: = Length + Width + Length + Width;
Writeln (‘Perimeter =’ , Perimeter);
Readln;
End.

Program Perimeter_of_Circle (input, output)


Var Radius, Perimeter: real;
Begin
WriteIn (‘Please enter a value for radius’);
Readln (Radius);
Perimeter: = 2*3.14*Radius;
Writeln (The Perimeter is ‘ , Perimeter);
Readln;
End.

 The Var line is for declaring


 The body is from (Begin to Readln)
 Write means output
 Read means Input

Program Area_of_Trapezium (input, output)


Var sideA, sideB, height, Area: real;
Begin
WriteIn (‘Please enter a value for sidea’);
Readln (sideA);
WriteIn (‘Please enter value for sideb’);
Readln (sideB);
WriteIn (‘Please enter a value for height’);
Readln (height)
Area: = 0.5*(sideA + sideB) * height
Writeln (‘Area =’, Area);
Readln;
End.

Information Technology
January 16th, 2023
Topic: Pseudocode

Write a pseudocode/algorithm to accept three values from a user and find their
average. The algorithm should also display their average.

Pseudocode
Read Num1, Num2, Num3
Sum = Num1 + Num2 + Num3
Average = Sum/3
Print Average

Program Average_of_three_numbers (input, output)


Var: integer;
Begin
Writeln (‘Please enter a value for length and width’);
Readln (Length, width);
Perimeter: = Length + Width + Length + Width;
Writeln (‘Perimeter =’, Perimeter);
Readln;
End.

Information Technology
January 18th, 2023
Topic: Pseudocode
1. You are to write a program, which calculates, and prints on screen, the time
required to travel 4800 miles at a speed of 600mph.

Pseudocode
Read Distance
Sum = Num1 + Num2 + Num3
Average = Sum/3
Print Average

You might also like