CFORBEGINNERS.COM

C Quiz on Functions

1. When using a function, what is the first thing you must do?
    a) prototype
    b) declare
    c) initialize

2. Where should the prototype be?
    a) after int main()
    b) before int main()
    c) a prototype isn't necessary

3. Here is a function, double numbers (int x), what is the name of this function?
    a) double
    b) int x
    c) numbers

4. From question 3, what data type will this function return?
    a) int
    b) double
    c) char

5. From question 4, what data type will this function take in?
    a) int
    b) double
    c) char

6. int my_function (double a), what type of data will this functions take in?
    a) double
    b) int & double
    c) int

7. Say we have a function, double subtract (double x, double y), what is the correct way to call this function in the main program?
    a) subtract (x)
    b) subtract (y)
    c) subtract (x,y)

8. If a variable is declared inside a function, what kind of variable is this?
    a) global variable
    b) local variable
    c) extended variable

9. If we have a function int stop (int n) , are we able to send it a different variable in the main program or does it have to be n.  For example, stop (x)
    a) yes
    b) no