# Basic Pascal Tutorial/Chapter 2/Solution

The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

2Fa - Solution (author: Tao Yue, state: unchanged) <delphi> (* 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: ');
write ('Enter the second number: ');
write ('Enter the third number: ');
write ('Enter the fourth number: ');
write ('Enter the fifth number: ');
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. </delphi>