-
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 value of y, the return value of the function f best approximates
-
- x y
- e x
- ln(1+ x)
- x x
- x y
Correct Option: B
The function is rewritten as Here initial value of s increments every time with a factor of (p)x / i
Thus it can be checked for every value. Here the assumption is that the value of y is very large so y approaches infinity So the series 1+ x + x2 / 2! + x3 / 3!...till infinity will have infinite terms & from our previous knowledge we know that this series is expansion of ex (exponential series) so. 1 + x + x2 / 2! + x3 / 3!...........till infinity = ex
Hence (b) is correct option.