homework 02

Name:


Date:

Class:

Homework 02

Directions: Answer the following questions. Homework answers must be
typed. For multiple choice questions, list the correct letter and write out the
answer. You should be able to type the information into the text boxes,
and immediately print it from the web page. If the homework goes to multiple
pages, you will need to staple the pages together so they do not come loose.
Regardless, always make sure you answer all questions in your own words.

This homework is 8 questions long.  It will be scored out of 7
questions.  Be prepared to discuss and questions you might have about this
during class on Monday, but this one is technically due Wednesday.

1) Write a switch statement which will print "too small" if
variable x is equal to 1 or 2, "just right" if variable x equals 3,
"a little big" if x equals 4, 5, or 6, and "Are you
guessing?" if x equals any other variable.

2) What is a function in C?

3) How many values can a function return in C?

4) Write a function called average, which takes two floats, averages their
values, and returns the answer:

5) What is a calling function?

6) What does the following function do?

void swap( int x, int y ) {

    // this function is to receive two
values from a calling function

    // swap their values, and the calling function will have the

    // values swapped when they are returned.

    // declare variables

    int temp;

    // swap the two values

    temp = x;

    x = y;

    y = temp;

}

7) It is syntactically correct.

True False

8) It is logically correct.

True False

 


Copyright ©2001-2002, Walter Wimberly – Instructor and all
’round Cool Guy – IADT