Difference between revisions of "Basic Pascal Tutorial/Chapter 1/Solution"
From Free Pascal wiki
Jump to navigationJump to search (New page: 1Ha - Solution Here's one way to solve the programming assignment in the previous section. <font color="#000000"> 1: </font><font color="#cc0000">(*</font><font color="#cc0000"> </font...) |
|||
Line 41: | Line 41: | ||
|[[Programming_Assignment|previous]] | |[[Programming_Assignment|previous]] | ||
|[[op_contents|contents]] | |[[op_contents|contents]] | ||
− | |[[ | + | |[[Input|next]] |
|} | |} |
Revision as of 22:46, 1 November 2007
1Ha - Solution
Here's one way to solve the programming assignment in the previous section.
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: *) 8: 9: program SumAverage; 10: 11: const 12: NumberOfIntegers = 5; 13: 14: var 15: A, B, C, D, E : integer; 16: Sum : integer; 17: Average : real; 18: 19: begin (* Main *) 20: A := 45; 21: B := 7; 22: C := 68; 23: D := 2; 24: E := 34; 25: Sum := A + B + C + D + E; 26: Average := Sum / NumberOfIntegers; 27: writeln ('Number of integers = ', NumberOfIntegers); 28: writeln ('Number1 = ', A); 29: writeln ('Number2 = ', B); 30: writeln ('Number3 = ', C); 31: writeln ('Number4 = ', D); 32: writeln ('Number5 = ', E); 33: writeln ('Sum = ', Sum); 34: writeln ('Average = ', Average) 35: end. (* Main *)
previous | contents | next |