Assessment Tool

Lecture 4:  Arithmetic Expressions

Activity:  Problem Recognition Tasks

In today's lecture, we discussed variables of type "int" and "double".  In your group (or as an individual) generate the algorithms to solve the following problems as well as describe the variable names and types you would use if implementing the algorithm in the C language.  Note that you need not write the entire C program.  An example solution to the first problem is given.

1.  A program to calculate the area of a circle given the radius as input.
    Input (what the user might type in):  radius
    Output (what would be displayed to the user):  area

Solution:

Algorithm:  area = PI * radius * radius

Variables and Types:  The type of variable area would be double and the type of variable radius would be double.  PI would be a symbolic constant equal to 3.14.

2.  A program to convert inches (given as a whole number) to miles, feet, and inches.
    Input:  inches (as a whole number)
    Output:  miles, feet, and inches

Solution:

Algorithm:  (Hint:  1 mile is equal to 5280 feet and 1 foot is equal to 12 inches)
 
 
 
 
 
 
 

Variables and Types:
 
 
 
 
 
 
 

3.  A program that calculates the amount of US money in dollars given the number of pennies, nickels, dimes, and quarters.
    Input:  number of pennies, nickels, dimes, and quarters
    Output:  US dollar amount

Solution:

Algorithm:  (Hint:  1 penny = .01 dollars, 1 nickel = .05 dollars, 1 dime = .10 dollars, 1 quarter = .25 dollars)
 
 
 
 
 
 
 

Variables and Types: