Solution 2

From Lazarus wiki
Revision as of 20:12, 9 November 2007 by Kees (talk | contribs) (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...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

2Fa - Solution

   1: (* Author:    Tao Yue
   2:    Date:      19 June 1997
   3:    Description:
   4:      Find the sum and average of five predefined numbers
   5:    Version:
   6:      1.0 - original version
   7:      2.0 - read in data from keyboard
   8: *)
   9:
  10: program SumAverage;
  11:
  12: const
  13:   NumberOfIntegers = 5;
  14:
  15: var
  16:   A, B, C, D, E : integer;
  17:   Sum : integer;
  18:   Average : real;
  19:
  20: begin    (* Main *)
  21:   write ('Enter the first number: ');
  22:   readln (A);
  23:   write ('Enter the second number: ');
  24:   readln (B);
  25:   write ('Enter the third number: ');
  26:   readln (C);
  27:   write ('Enter the fourth number: ');
  28:   readln (D);
  29:   write ('Enter the fifth number: ');
  30:   readln (E);
  31:   Sum := A + B + C + D + E;
  32:   Average := Sum / 5;
  33:   writeln ('Number of integers = ', NumberOfIntegers);
  34:   writeln;
  35:   writeln ('Number1:', A:8);
  36:   writeln ('Number2:', B:8);
  37:   writeln ('Number3:', C:8);
  38:   writeln ('Number4:', D:8);
  39:   writeln ('Number5:', D:8);
  40:   writeln ('================');
  41:   writeln ('Sum:', Sum:12);
  42:   writeln ('Average:', Average:10:1);
  43: end.
previous contents next