Sign in Join
Wiki copytemporary

Basic Pascal Tutorial/Chapter 2/Solution: what changed

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

Title: Basic Pascal Tutorial/Chapter 2/Solution

OldNewLine
1+2Fa - Solution (author: Tao Yue, state: unchanged)
2+
3+``` pascal
4+(* Author: Tao Yue
5+ Date: 19 June 1997
6+ Description:
7+ Find the sum and average of five predefined numbers
8+ Version:
9+ 1.0 - original version
10+ 2.0 - read in data from keyboard
11+*)
12+
13+program SumAverage;
14+
15+const
16+ NumberOfIntegers = 5;
17+
18+var
19+ A, B, C, D, E : integer;
20+ Sum : integer;
21+ Average : real;
22+
23+begin (* Main *)
24+ write ('Enter the first number: ');
25+ readln (A);
26+ write ('Enter the second number: ');
27+ readln (B);
28+ write ('Enter the third number: ');
29+ readln (C);
30+ write ('Enter the fourth number: ');
31+ readln (D);
32+ write ('Enter the fifth number: ');
33+ readln (E);
34+ Sum := A + B + C + D + E;
35+ Average := Sum / 5;
36+ writeln ('Number of integers = ', NumberOfIntegers);
37+ writeln;
38+ writeln ('Number1:', A:8);
39+ writeln ('Number2:', B:8);
40+ writeln ('Number3:', C:8);
41+ writeln ('Number4:', D:8);
42+ writeln ('Number5:', E:8);
43+ writeln ('================');
44+ writeln ('Sum:', Sum:12);
45+ writeln ('Average:', Average:10:1);
46+end.
47+```
48+
49+---
50+*From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 2/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