Exercise 1.3
- Identify, with reasons, any illegal identifiers.
- Turing
- next_character
- const
- int
- max2
|
- 3rdPlace
- initalLetter
- case
- home-form
- a123456
|
- A program is to be written that records the results of a coin-tossing experiment.
The program will need variables to record the number of heads, the number of tails, the total number of throws, the percentage of heads (correct to 4 decimal places), and the experimenter's
name. Write a declaration to reserve spaces of the appropriate types for these variables. Be sure to use identifier names that show clearly the purpose of each variable.
- State three advantages of named constants.
- For each legal constant definition, state the type of the constant. If the
definition is not legal, give a reason.
- YEAR := 1990
- const FIRST_ROW = "A"
- const TAX_RATE := .25
- const initialSpeed := 6.317e2
- const QUOTE := "\""
|
- const SUPERVISOR := "Ziggy T."
-
const BIG := maxint
- const bigNeg = -maxint
- const last-row := "X"
- const HOME_PHONE = "555-1212"
|
- The following program has an error. Copy the program and run it on your system
to see what type of error message you get.
% This program is incorrect because it tries to change the value of a constant.
const test := 0
put test
test := 1
put test
|
|