Finding Integral Part of Numbers of the Form a^b Where a Is Irrational
Consider the ...
Question
Consider the following C function.
float f (float x, int y)
{
float p, s; int i;
for (s = 1, p = 1, i = 1; i < y; i ++)
{
p* = x/i;
s + = p:
}
return s;
}
For large values of y, the return value of the function f best approximates
A
ln(1 + x)
No worries! We‘ve got your back. Try BYJU‘S free classes today!
B
xx
No worries! We‘ve got your back. Try BYJU‘S free classes today!
C
ex
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
D
xy
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution
The correct option is Cex The given function f is not recursive, so consider the folowing iteration method.
i p s
p =p*xi s = s + p
initilize 1 1 1
1 p = x s = 1 + x
2 p = x. x2 s = 1 + x + x22
3 p = x22.x3 s = 1 + x + x22 + x36
4 p = x36. x4 s = 1 + x + x22 + x36 + x424
5 p = x424. x5 s = 1 + x + x22 + x36 + x424 + x5120
For large value of y assume y →∞ then i also tends to infinite it means increment of for loop may tends to infinite. In the given function we choose y as a large integer but not infinite. The return value of the function f is s.