Introduction to Computer Science:
Assignment 17:  While Loops and Functions
   Sewickley Academy, 2000-2001

See Course Home Page.
 
Date Assigned: Thu Oct-26
Date Due: Fri Oct-27

0.  Reminder:  YOU MUST WORK ALONE ON THIS ASSIGNMENT.  You may not work with anyone else on this assignment.

1.  Review for quiz tomorrow on While Loops and Functions, which we reviewed in class today.  This will be a closed-book, closed-note quiz (just you and a compiler).

2a.  Write the following functions (these should take <10 minutes to write all of them; some we did in class, others you did for the most part on previous assignments and quizzes):

int square(int x)
int power(int x, int y)
int max(int x, int y)
int max(int x, int y, int z)
int min(int x, int y)
int min(int x, int y, int z)
int average(int x, int y, int z)

Hint:  As a reminder of how to do this, here is a function which computes the product of 3 numbers:

int product(int x, int y, int z)
{
    int result;

    result = x * y * z;
    return result;
}

2b.  Next, modify your answer to Assignment 16 so that your main function uses the min, max, and average functions above instead of directly computing the values.  You will only have to use 3 of the functions you defined for this task.

2c.  Further modify your main function so that it also uses the other functions you defined in some interesting way.  For example (and you may not use this example), print out the square of the average.  Be creative.  Make sure it is obvious to the user what you are printing out, and also obvious to a programmer looking at your code what it does.

3.  What to submit:  At the start of class, immediately launch Visual C++ with this program, but also have a physical printout of your program to turn in.

See Course Home Page.