# Difference between revisions of "Solution 2"

From Lazarus wiki

m |
m (Fixed syntax highlighting) |
||

(One intermediate revision by one other user not shown) | |||

Line 1: | Line 1: | ||

{{Solution 2}} | {{Solution 2}} | ||

+ | {{TYNavigator|Programming_Assignment_2|Sequential_control}} | ||

2Fa - Solution (author: Tao Yue, state: unchanged) | 2Fa - Solution (author: Tao Yue, state: unchanged) | ||

− | <syntaxhighlight> | + | |

+ | <syntaxhighlight lang=pascal> | ||

(* Author: Tao Yue | (* Author: Tao Yue | ||

Date: 19 June 1997 | Date: 19 June 1997 | ||

Line 47: | Line 49: | ||

end. | end. | ||

</syntaxhighlight> | </syntaxhighlight> | ||

− | {| | + | |

− | + | {{TYNavigator|Programming_Assignment_2|Sequential_control}} | |

− | |||

− | |||

− |

## Latest revision as of 13:07, 26 February 2020

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

◄ | ▲ | ► |

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.
```

◄ | ▲ | ► |