Sign in Join
Wiki copytemporary

Basic Pascal Tutorial/Chapter 1/Programming Assignment: what changed

Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
111H - Programming Assignment (author: Tao Yue, state: changed)
22
33Now you know how to use variables and change their value. Ready for your first programming assignment?
44
55But there's one small problem: you haven't yet learned how to display data to the screen! How are you going to know whether or not the program works if all that information is still stored in memory and not displayed on the screen?
66
77So, to get you started, here's a snippet from the next few lessons. To display data, use:
88
99``` pascal
1010writeln (argument_list);
1111```
1212
1313The argument list is composed of either strings or variable names separated by commas. An example is:
1414
1515``` pascal
1616writeln ('Sum = ', sum);
1717```
1818
1919Here's the programming assignment for Chapter 1:
2020
2121Find the sum and average of five integers. The sum should be an integer, and the average should be real. The five numbers are: 45, 7, 68, 2, and 34.
2222
2323Use a constant to signify the number of integers handled by the program, i.e. define a constant as having the value 5.
2424
2525Then print it all out! The output should look something like this:
2626
27-```
27+```text
2828Number of integers = 5
2929Number 1 = 45
3030Number 2 = 7
3131Number 3 = 68
3232Number 4 = 2
3333Number 5 = 34
3434Sum = 156
3535Average = 3.1200000000E+01
3636```
3737
3838As you can see, the default output method for real numbers is scientific notation. Chapter 2 will explain you how to format it to fixed-point decimal.
3939
4040To see one possible solution of the assignment, go to the next page.
4141
4242---
4343*From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 1/Programming Assignment", as it stood on 2022-08-20 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history