Sign in Join
Wiki copytemporary

Basic Pascal Tutorial/Chapter 1/Solution: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Basic Pascal Tutorial/Chapter 1/Solution

OldNewLine
1+1Ha - Solution (author: Tao Yue, state: changed)
2+
3+Here's one way to solve the programming assignment in the previous section.
4+
5+``` pascal
6+(* Author: Tao Yue
7+ Date: 19 June 1997
8+ Description:
9+ Find the sum and average of five predefined numbers
10+ Version:
11+ 1.0 - original version
12+*)
13+
14+program SumAverage;
15+
16+const
17+ NumberOfIntegers = 5;
18+
19+var
20+ A, B, C, D, E : integer;
21+ Sum : integer;
22+ Average : real;
23+
24+begin (* Main *)
25+ A := 45;
26+ B := 7;
27+ C := 68;
28+ D := 2;
29+ E := 34;
30+ Sum := A + B + C + D + E;
31+ Average := Sum / NumberOfIntegers;
32+ writeln ('Number of integers = ', NumberOfIntegers);
33+ writeln ('Number 1 = ', A);
34+ writeln ('Number 2 = ', B);
35+ writeln ('Number 3 = ', C);
36+ writeln ('Number 4 = ', D);
37+ writeln ('Number 5 = ', E);
38+ writeln ('Sum = ', Sum);
39+ writeln ('Average = ', Average)
40+end. (* Main *)
41+```
42+
43+---
44+*From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 1/Solution", as it stood on 2022-08-20 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history