Skip to content
Related Articles

Related Articles

GATE | GATE-CS-2014-(Set-2) | Question 50

Improve Article
Save Article
  • Difficulty Level : Hard
  • Last Updated : 28 Jun, 2021
Improve Article
Save Article

Consider the following function

double f(double x){
  if (abs(x*x - 3) < 0.01) return x;
  else return f(x/2 + 1.5/x);

Give a value q (to 2 decimals) such that f(q) will return q:_____.

(A) 1.73
(B) 2.24
(C) 4.22
(D) 3.42

Answer: (A)

Explanation: anil_ds_50

This solution is contributed by Anil Saikrishna Devarasetty

Another One:
The main thing to note is the expression “abs(x*x – 3) < 0.01″ inside the if condition. The function would return x when x2 is close to 0 (smaller than 0.01) which means when x is close to square root of 3. Square root of 3 is 1.732.–>

Quiz of this Question

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!