C Questions and Answers – Mathematical functions – 2

«
»

This set of C Multiple Choice Questions & Answers focuses on “Mathematical functions – 2”.

1. What does the given C code do?

advertisement
double atan2 (double y, double x);

a) The atan2 function returns the arc tangent of x/y
b) The atan2 function returns the arc tangent of x
c) The atan2 function returns the arc tangent of y/x
d) The atan2 function returns the arc tangent of y
View Answer

Answer: c
Explanation: The atan2 function returns the arc tangent of y/x, in the range [-pi,+pi] radians.

2. The cos function computes the cosine of x.
a) measured in radians
b) measured in degrees
c) measured in gradian
d) measured in milliradian
View Answer

Answer: a
Explanation: The cos function computes the cosine of x (measured in radians).

3. The function computes the hyperbolic cosine of x.
a) cos(x)
b) cosine(x)
c) cosh(x)
d) cosineh(x)
View Answer

Answer: c
Explanation: The cosh() function computes the hyperbolic cosine of x. The cosh function returns the hyperbolic cosine value.
advertisement

4. What error occurs if the magnitude of x is too large in sinh(double x)?
a) domain error
b) range error
c) no error
d) zero is returned
View Answer

Answer: b
Explanation:The sinh() function computes the hyperbolic sine of x. A range error occurs if the magnitude of x is too large.If the result overflows i.e the magnitude of the result is too large to be represented in an object of the specified type).

5. Which of the following is the correct code?
a) tanh(double x)
b) tanh double x
c) tanhdouble x
d) tanhdoublex
View Answer

Answer: a
Explanation: The correct code is tanh(double x). The tanh() function computes the hyperbolic tangent of x.

6. Name the function that breaks a floating-point number into a normalized fraction and an integral power of 2.
a) exp()
b) frexp()
c) Idexp()
d) modf()
View Answer

Answer: b
Explanation: The frexp() function breaks a floating-point number into a normalized fraction and an integral power of 2.

7. The function computes the exponential function of x.
a) exp(x)
b) frexp(x)
c) frexp x
d) exp x
View Answer

Answer: d
Explanation: The exp(x) function computes the exponential function of x.

8. The ldexp() function multiplies a floating-point number by an integral power of 2.
a) true
b) false
View Answer

Answer: a
Explanation: double ldexp(double x, int exp);
The ldexp function multiplies a floating-point number by an integral power of 2. A range error may occur. The ldexp() function returns the value of x times 2 raised to the power exp.
advertisement

9. What will be the output of the following C code?

double log (double -x);

a) returns natural logarithm of x
b) range error
c) domain error
d) returns natural logarithm of -x
View Answer

Answer: c
Explanation: The log() function is used to compute the natural logarithm of x. If the argument is negative, a domain error occurs. A range error may occur if the argument is zero.

10. Which of the given function is a library function under the header math.h?
a) log10()
b) log20()
c) log30()
d) log50()
View Answer

Answer: a
Explanation: double log10 (double x);
The log10 function computes the base-ten logarithm of x. If the argument is negative, a domain error occurs. If the argument is zero, a range error may occur.

Sanfoundry Global Education & Learning Series – C Programming Language.

advertisement
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn