Review Questions

I l @ ve RuBoard

Review Questions

  1. What is the difference between an actual argument and a formal argument?

  2. Write ANSI C function headings for the following functions described. Note we are asking just for the headings, not the body.

    1. donut() takes an int argument and prints that number of 0s .

    2. gear() takes two int arguments and returns type int .

    3. stuff_it() takes a double and the address of a double variable and stores the first value in the given location.

  3. Write ANSI C function headings for the following functions described. Note that you need write only the headings, not the body.

    1. n_to_char() takes an int argument and returns a char .

    2. digits() takes a double argument and an int argument and returns an int .

    3. random() takes no argument and returns an int .

  4. Devise a function that returns the sum of two integers.

  5. What changes, if any, would you need to make to have the function of Question 4 add two double numbers instead?

  6. Devise a function alter() that takes two int variables x and y and changes their values to their sum and their difference, respectively.

  7. Is anything wrong with this function definition?

     void salami(num) {    int num, count;    for (count = 1; count <= num; num++)        printf(" O salami mio!\n"); } 
  8. Write a function that returns the largest of three integer arguments.

  9. Given the following output:

     Please choose one of the following: 1) copy files            2) move files 3) remove files          4) quit Enter the number of your choice: 
    1. Write a function that displays a menu of four numbered choices and asks you to choose one. (The output should look like the preceding .)

    2. Write a function that has two int arguments: a lower limit and an upper limit. The function should read an integer from input. If the integer is outside the limits, the function should print a menu again (using the function from part a. of this question) to reprompt the user , and get a new value. When an integer in the proper limits is entered, the function should return that value to the calling function.

    3. Write a minimal program using the functions from parts a. and b. of this question. By minimal, we mean it need not actually perform the actions promised by the menu; it should just show the choices and get a valid response.

I l @ ve RuBoard


C++ Primer Plus
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2000
Pages: 314
Authors: Stephen Prata

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net