Exercise 1.7
- What will this program print?
put "Here we are " ..
put "finally,"
put ""
put "at the end " ..
put "of" ..
put ""
put ""
put "Chapter 1"
- What will this program print?
put "To give the variable \"doubleQuote\"" ..
put " the value of a double quote,"
put "use the following assignment:"
put "doubleQuote := \"\\\"\""
- Classify each constant as being int, real, char, string, or illegal. If the constant
is illegal, explain.
- "5.2e-3"
- -0
- '''
- "A string"
|
- '7'
- 37.
- .26E1
- 63.9E0.5
|
- Write without using E notation.
- 1E-3
- 6.35E0
|
- 0.007E-2
- 73.08E5
|
- State, with reasons, which of the following are illegal Turing identifiers.
- velocity
- firstValue
- 15March
- Get
- x27
|
- last-value
- case
- ending
- time.at.start
- time at end
|
- For each legal constant definition, state the type of the constant. If the definition
is illegal, give a reason.
- STAR = "*"
- const PI = 0.314159e1
- const DATE := "October 31"
|
- const leastValue := -10000
- const SUM := 2 + 3
- const SCALE_FACTOR := -2.0E2.0
|
- Give two different statements that could be used to give a value to the
int variable number.
- The program shown is full of errors. Copy the program and correct the
mistakes.
Here's a comment
var a:= integer b:= real c:= char
const MAX : 50; MIN : 1
a = 75.6
put "Here is the integer, a
put "MAX = " MAX "MIN = " MIN
b := 7.2
put "Here is the "real"" b
c := *
put "And here's the char", c
- Rewrite the following program using the formatting style
shown in this text.
const PI := 3.14159 var first,last:string get first get last put "Hi, mom, it's me ",first,last
put "Are we having ", PI, " for dessert tonight?"
- What would this program print given input of DAVID SKY?
- Write a program that draws a picture of a car.
- Draw a red square that is 100 x 100 at the bottom right corner. Draw a green circle that has a radius of 50 and just touches the top left corner of the screen. Draw a blue triangle with a black outline that goes through the following points: (150,150), (150, 250), (300, 200).
|
|