What will be the output of the following code? int f(int n) { static int a =…
PYQ Accenture Hiring Assessment 2024
What will be the output of the following code?
int f(int n)
{
static int a = 0;
if (n <= 0)
{
return 1;
}
if (n > 3)
{
a = n;
return f(n - 2) + 2;
}
return f(n - 1) + a;
}
int main()
{
printf("Result:%d", f(5));
return 0;
}- A.
19
- B.
9
- C.
12
- D.
18
Attempted by 90 students.
Sign up free to check your answer
Sign up freeLoading lesson…

