aliensbrain
  • Home
  • Study
  • Quizzes
  • 🎤AI Practicefree
  • Notebooks
  • Community
  • Sign in
  • Computer Science (GATE Exam) 2007 - Previous Question Paper Solution
  • Consider the following C function: ```c int f(int n) { st...
Multiple choice

Consider the following C function:

int f(int n) {
  static int r = 0;
  if (n <= 0) return 1;
  if (n > 3) {
    r = n;
    return f(n - 2) + 2;
  }
  return f(n - 1) + r;
}

What is the value of f (5)?

  1. 5

  2. 7

  3. 9

  4. 18

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Keep practicing — related questions

  • Consider the following C function int f(int n) { static int i = 1; if (n >= 5) return n; n = n + i; i++; re...
  • Consider the following C functions: int f1 (int n) { If(n == 0 | |n == 1) return n; else return(2*f1(n-1) +...
  • Consider the following C functions: int f1(int n) { If(n == 0 | | n == 1) return n; else return (2 * f1(n -...
  • Consider the following recursive C function that takes two arguments unsigned int foo (unsigned int n, unsi...
  • Consider the following recursive C function that takes two arguments unsigned int foo (unsigned int n, unsi...
  • Consider the following function. int unknown (int n) { int i, j, k 0; for i n / 2; i <- n; i + +) for j = 2...
  • Consider the following C functions: int f1 (int n) { If(n == 0 | |n == 1) return n; else return(2*f1(n-1) +...
  • What will be the output of the following function? main() { static int var = 5; printf(%d ,var--); if(var) ...
Play the full quiz 🎤 Practise this topic out loud
Advertisement
© Aliensbrain | all rights reserved
  • About
  • Contact
  • Terms and Condition
  • Privacy Policy