Question
What is the output of the following recursive function
call func(3) ? int func ( int n) {Â Â Â Â Â Â Â Â Â Â if (n == 0 ) return 1 ; Â Â Â return n * func(n - 1 ); }Solution
This function computes the factorial of n . Factorial is defined as n!=n×(n−1)× ⋯ ×1 . For n=3 :
- func(3) calls 3 * func(2) .
- func(2) calls 2 * func(1) .
- func(1) calls 1 * func(0) .
- func(0) returns 1 (base case).
- Option A (1): Only the base case returns 1 . This does not account for recursive multiplication.
- Option B (3): This is the input but not the factorial result.
- Option D (9): This result might confuse with 3² , which is unrelated to factorial.
- Option E (27): This is 3^3 .
Select the correct Antonym of the given word.
adversary
A person who is absolutely necessary for someone or something
Find the word with the appropriate similar meaning of the word in Italic from the options given:
The CEO appreciated the manager's astute decis...
Find out the wrongly spelt word and mark that option as the answer.
Find the appropriate answer.
Select the most appropriate synonym of the given word
Profuse
Person who is nervous and shy
out of the four alternatives, choose the one which best expresses the meaning of the given word and indicate your correct answer.
Select the most appropriate ANTONYM of the given word.
Jovial
- Each of the following questions consists of two words which have a relationship to each other. This is followed by four pairs of related words. Choose the ...