Q40
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:_____.
Show answer without attempting
Answer: 1.72 to 1.74
GATE CS · Recursion · 2 questions
2 Recursive Programs questions from GATE CS papers (2014), each with the official answer key. Part of Recursion. Answer any question right here and it is marked straight away, or practise them one at a time.
double f(double x){
if( abs(x*x - 3) < 0.01) return x;
else return f(x/2 + 1.5/x);
}Answer: 1.72 to 1.74
int f(int j)
{
static int i = 50;
int k;
if (i == j)
{
printf("something");
k = f(i);
return 0;
}
else return 0;
}Answer: D
0/20 correct0 marks