Basic Pascal Tutorial/Chapter 2/Solution
Sent here from Solution 2.
Deutsch · English · Français · Български · 中文(中国) · 日本語
2Fa - Solution (author: Tao Yue, state: unchanged)
(* Author: Tao Yue
Date: 19 June 1997
Description:
Find the sum and average of five predefined numbers
Version:
1.0 - original version
2.0 - read in data from keyboard
*)
program SumAverage;
const
NumberOfIntegers = 5;
var
A, B, C, D, E : integer;
Sum : integer;
Average : real;
begin (* Main *)
write ('Enter the first number: ');
readln (A);
write ('Enter the second number: ');
readln (B);
write ('Enter the third number: ');
readln (C);
write ('Enter the fourth number: ');
readln (D);
write ('Enter the fifth number: ');
readln (E);
Sum := A + B + C + D + E;
Average := Sum / 5;
writeln ('Number of integers = ', NumberOfIntegers);
writeln;
writeln ('Number1:', A:8);
writeln ('Number2:', B:8);
writeln ('Number3:', C:8);
writeln ('Number4:', D:8);
writeln ('Number5:', E:8);
writeln ('================');
writeln ('Sum:', Sum:12);
writeln ('Average:', Average:10:1);
end.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.
Edited on wiki.freepascal.org by 6 people, 2007–2022
From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.
| When | Who | What changed |
|---|---|---|
| Kees | New page: 2Fa - Solution <font color="#000000"> 1:</font> <font color="#cc0000">(*</font><font color="#cc0000"> </font><font color="#cc0000">Author:</font><font color="#cc0000"> </font><font colo... | |
| Kees | ||
| Kees | ||
| Kees | ||
| Vincent | Text replace - "delphi>" to "syntaxhighlight>" (minor) | |
| Swen | (minor) | |
| FTurtle | ||
| Trev | Fixed syntax highlighting (minor) | |
| Kai Burghardt | Kai Burghardt moved page Solution 2 to Basic Pascal Tutorial/Chapter 2/Solution: tidy up main name space: create subpage hierarchy for basic Pascal tutorial [cf. [[Special: PermaLink/149778#Cluttering of... (minor) | |
| Kai Burghardt | bypass redirects [cf. discussion] | |
| Kai Burghardt | bypass language bar/categorization template redirect [cf. discussion] (minor) |
Talk about this page
Nobody has opened a bench for this page yet. Sign in to open one.
