CS21 Spring 2005
Homework 2
Due Sunday, January 23 before 11:30pm
Answer the following Review Questions from the C book on your own,
but do not turn them in. I will post answers on the CS21 web page
next week.
 Chapter 2 Review Questions: 36, 11, 1620, 22, 23 (pages 5354)
For those of you without textbooks, you can pick up print outs
of the review questions outside my office door, and I'll hand them
out in class on Thursday.
Please complete the following 3 programs and turn
them in using cs21handin. You should work on this assignment by yourself
(no partners).

Write a program that asks the user for the radius of a sphere, and then
computes the volume of that sphere (V) using the formula:
where pi is approximately 3.14159. Note: there is no "raise to a power"
operator in C. Given the arithmetic operators from Chapter 2, how can
you write an expression that achieves the desired result?
Remember to print out a prompt to the user to enter the input values,
and then to print out the result in a way that would make sense to
a user of your program. For example, here is the output of my program
when a user enters 2.3 as the radius:
This is a program that computes the volume of a sphere given its radius.
Enter the sphere's radius as a decimal: 2.3
The volume of a sphere with radius 2.3 is 50.965

Write a program that asks the user to enter four numbers, and
then computes the average of those four numbers.
 Write a program that converts a length in yards to the corresponding length
in meters and centementers. For example, 2.3 yards = 2 m 10.312 cm.
Your program should output the number of meters followed by 'm' and the
number of centimeters followed by 'cm' as in the example above.
The conversion factors you might need are:
1 yard = 3 feet = 0.9144 meters
1 meter = 100 centimeters
Please use the cs21handin command to turn in your homework.