Algorithm Workbench
1.
Design an algorithm that prompts the user to enter his or her height and stores the user’s input
in a variable named height.
Declare Real Height
Display “What is your height?”
Input Height
2.
Design an algorithm that prompts the user to enter his or her favorite color and stores the user’s
input in a variable named color.
Declare String color
Display “What is your favorite color?”
Input color
3.
Write assignment statements that perform the following operations with the variables a, b, and
c.
a.
Adds 2 to a and stores the result in b
Set b = 2+a
b.
Multiples b times 4 and stores the result in b
Set b = b*4
c.
Divides a by 3.14 and stores the result in b
Set b = a/3.14
d.
Subtracts 8 from b and stores the result in a
Set a = b8
4.
Assume the variables result, w, x, y, and z are all integers, and that w = 5, x = 4, y = 8, and z = 2.
What value will be stored in result in each of the following statements?
a.
Set result = x + y
12
b.
Set result = z * 2
4
c.
Set result = y / x
2
d.
Set result = y – z
6
5.
Write a pseudocode statement that declares the variable cost so it can hold real numbers.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '14

Click to edit the document details