CameraIcon
CameraIcon
SearchIcon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
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 C ex
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.

s = 1 + x + x22 + x36 + x424 + x5120... +

s = 1 + x + x2!2 + x3!3 + x4!4 + x5!5... +

s = ex

flag
Suggest Corrections
thumbs-up
0
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Integral Part Problems
MATHEMATICS
Watch in App
Join BYJU'S Learning Program
CrossIcon