Exercise: Python

Questions for: Functions

In C all functions except main() can be called recursively.
A:
True
B:
False
C:
D:
Answer: B
Any function including main() can be called recursively.
If return type for a function is not specified, it defaults to int
A:
True
B:
False
C:
D:
Answer: A

True, The default return type for a function is int.

Functions cannot return more than one value at a time
A:
True
B:
False
C:
D:
Answer: A

True, A function cannot return more than one value at a time. because after returning a value the control is given back to calling function.

A function cannot be defined inside another function
A:
True
B:
False
C:
D:
Answer: A

A function cannot be defined inside the another function, but a function can be called inside a another function.

Which of the following statements are correct about the function?
long fun(int num)
{
    int i;
    long f=1;
    for(i=1; i<=num; i++)
        f = f * i;
    return f;
}
A:
The function calculates the value of 1 raised to power num.
B:
The function calculates the square root of an integer
C:
The function calculates the factorial value of an integer
D:
None of above
Answer: C

Yes, this function calculates and return the factorial value of an given integer num.

Ad Slot (Above Pagination)
Quiz