Exercise: Python

Questions for: Functions

Every function must return a value
A:
Yes
B:
No
C:
D:
Answer: B

No, If a function return type is declared as void it cannot return any value.

Functions cannot return a floating point number
A:
Yes
B:
No
C:
D:
Answer: B

A function can return floating point value.

Example:


#include <stdio.h>
float sub(float, float); /* Function prototype */

int main()
{
    float a = 4.5, b = 3.2, c;
    c = sub(a, b);
    printf("c = %f\n", c);
    return 0;
}
float sub(float a, float b)
{
   return (a - b);
}

Output:
c = 1.300000

Names of functions in two different files linked together must be unique
A:
True
B:
False
C:
D:
Answer: A

True, If two function are declared in a same name, it gives "Error: Multiple declaration of function_name())".

A function may have any number of return statements each returning different values.
A:
True
B:
False
C:
D:
Answer: A

True, A function may have any number of return statements each returning different values and each return statements will not occur successively.

Functions can be called either by value or reference
A:
True
B:
False
C:
D:
Answer: A

True, A function can be called either call by value or call by reference.

Example:

Call by value means c = sub(a, b); here value of a and b are passed.

Call by reference means c = sub(&a, &b); here address of a and b are passed.

Ad Slot (Above Pagination)
Quiz