C Questions and Answers – Mathematical Functions – 1

This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Mathematical Functions – 1”.

Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.

1. Which of the following header declares mathematical functions and macros?
a) math.h
b) assert.h
c) stdmat. h
d) stdio. h
View Answer

Answer: a
Explanation: The header file math.h declares all the mathematical functions and macros.

2. All the functions in this library take as a parameter and return as the output.
a) double, int
b) double, double
c) int, double
d) int, int
View Answer

Answer: b
Explanation: All the function in this math library takes double as a parameter and gives double as the result.
advertisement
advertisement

3. HUGE_VAL macro is used when the output of the function may not be ___________
a) floating point numbers
b) integer number
c) short int
d) long int
View Answer

Answer: a
Explanation: HUGE_VAL macro is used when the result of a function may not be representable as a floating point number.

4. What error occurs if an input argument is outside the domain over which the mathematical function is defined?
a) domain error
b) range error
c) no error
d) domain and range error
View Answer

Answer: a
Explanation: A domain error occurs if an input argument is outside the domain over which the mathematical function is defined.

5. A range error occurs if the result of the function cannot be represented as a value.
a) int
b) short int
c) double
d) float
View Answer

Answer: c
Explanation: if the result of the function cannot be represented as a double value, a range error occurs. If the result overflows (the magnitude of the result is so large that it cannot be represented in an object of the specified type), the function returns the value of the macro HUGE_VAL, with the same sign as the correct value of the function.

6. If the result overflows, the function returns the value of the macro HUGE_VAL, carrying the same sign except for the _________ function as the correct value of the function.
a) sin
b) cos
c) cosec
d) tan
View Answer

Answer: d
Explanation: If the result overflows i.e the magnitude of the result is too large to be represented in an object of the specified type, the function returns the value of the macro HUGE_VAL, with the same sign except for the tan function as the correct value of the function.
advertisement

7. If the result underflow, the function returns zero.
a) true
b) false
View Answer

Answer: a
Explanation: If the result underflows i.e the magnitude of the result is very small to be represented in an object of the specified type, the function returns zero.

8. For the given math function, an error occurs if the arguments are not in the range [-1, +1].

double acos(double x);
advertisement

a) range error
b) domain error
c) no error
d) domain and range error
View Answer

Answer: b
Explanation: The acos() function is used to compute the principal value of the inverse of cosine of x. A domain error occurs for arguments not in the range [-1, +1].

9. Which function returns the arc sine in the range [-pi/2, +pi/2] radians?
a) arcsin()
b) asin()
c) sin()
d) asine()
View Answer

Answer: b
Explanation: The asin() function is used to compute the principal value of the inverse of sine of x. A domain error occurs for arguments not in the range [-1, +1].

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

double x, deg, rad;
x = 1.0;
val = 180.0 / 3.14;
deg = atan (x) * val;
printf("The arc tangent of %lf is %lf degrees", x, deg);

a) The arc tangent of 1.000000 is 45.000000 degrees
b) The arc tangent of 1.000 is 45.000degrees
c) The arc tangent of 1 is 45 degrees
d) The arc tangent of 1.0000is 45.0000degrees
View Answer

Answer: a
Explanation: double atan(double x) returns the arc tangent of x in radians.

Sanfoundry Global Education & Learning Series – C Programming Language.

To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.