|CSC 161||Grinnell College||Spring, 2009|
|Imperative Problem Solving and Data Structures|
This laboratory exercise provides practice with reading data, computing, and printing within a C program.
Consider the program quarts-1.c from the annotated program in today's reading.
Write a program that reads a person's weight in pounds and computes (and prints) the weight in grams (1 pound avoirdupois = approximately 453.59 grams).
Run your program with a few test cases. What values might you test (ideally, they should exercise the program's capabilities but be easy for you as programmer to check)?
Write a program to read a person's height in feet and inches and print the person's height in centimeters (1 inch = approximately 2.54 centimeters). The output of the program should present an equation of the form:
5 feet 6.2 inches = 168.15 centimeters
That is, the number of feet should be given as an integer, the number of inches to 1 decimal place, and the number of centimeters to 2 decimal places. One space should separate each number from text or the equal sign.
Write a program that reads the radius of a circle and prints the circle's area and circumference in the format illustrated below:
radius area circumference 2.5 19.63 15.71
That is, the radius, area, and circumference should appear under headings, the radius should be printed to 1 decimal place, and the area and circumference to 2 decimal places.
Write a program that reads the coefficients a, b, c of a quadratic equation: a x2 + b x + c = 0, and prints the roots of the equation to two decimal places.
Do King, Programming Project 3.2 (page 50).
Do King, Programming Project 3.4 (page 50).
Do King, Programming Project 3.6 (page 51).
This document is available on the World Wide Web as
created 13 May 1998
last revised 29 January 2009
|For more information, please contact Henry M. Walker at firstname.lastname@example.org.|