# Difference between revisions of "Basic Pascal Tutorial/Chapter 1/Solution"

From Free Pascal wiki

Jump to navigationJump to searchm (Kai Burghardt moved page Solution to Basic Pascal Tutorial/Chapter 1/Solution: tidy up main name space: create subpage hierarchy for basic Pascal tutorial [cf. [[Special: PermaLink/149778#Cluttering of m...) |
m (Readability) |
||

Line 2: | Line 2: | ||

{{TYNavigator|Programming_Assignment|Input}} | {{TYNavigator|Programming_Assignment|Input}} | ||

− | 1Ha - Solution (author: Tao Yue, state: | + | 1Ha - Solution (author: Tao Yue, state: changed) |

Here's one way to solve the programming assignment in the previous section. | Here's one way to solve the programming assignment in the previous section. | ||

Line 33: | Line 33: | ||

Average := Sum / NumberOfIntegers; | Average := Sum / NumberOfIntegers; | ||

writeln ('Number of integers = ', NumberOfIntegers); | writeln ('Number of integers = ', NumberOfIntegers); | ||

− | writeln (' | + | writeln ('Number 1 = ', A); |

− | writeln (' | + | writeln ('Number 2 = ', B); |

− | writeln (' | + | writeln ('Number 3 = ', C); |

− | writeln (' | + | writeln ('Number 4 = ', D); |

− | writeln (' | + | writeln ('Number 5 = ', E); |

writeln ('Sum = ', Sum); | writeln ('Sum = ', Sum); | ||

writeln ('Average = ', Average) | writeln ('Average = ', Average) |

## Revision as of 12:39, 5 May 2022

│
**български (bg)** │
**Deutsch (de)** │
**English (en)** │
**français (fr)** │
**日本語 (ja)** │
**한국어 (ko)** │
**русский (ru)** │
**中文（中国大陆） (zh_CN)** │

◄ | ▲ | ► |

1Ha - Solution (author: Tao Yue, state: changed)

Here's one way to solve the programming assignment in the previous section.

```
(* Author: Tao Yue
Date: 19 June 1997
Description:
Find the sum and average of five predefined numbers
Version:
1.0 - original version
*)
program SumAverage;
const
NumberOfIntegers = 5;
var
A, B, C, D, E : integer;
Sum : integer;
Average : real;
begin (* Main *)
A := 45;
B := 7;
C := 68;
D := 2;
E := 34;
Sum := A + B + C + D + E;
Average := Sum / NumberOfIntegers;
writeln ('Number of integers = ', NumberOfIntegers);
writeln ('Number 1 = ', A);
writeln ('Number 2 = ', B);
writeln ('Number 3 = ', C);
writeln ('Number 4 = ', D);
writeln ('Number 5 = ', E);
writeln ('Sum = ', Sum);
writeln ('Average = ', Average)
end. (* Main *)
```

◄ | ▲ | ► |