Here is a listing of C++ interview questions on “Standard Mathematical Functions” along with answers, explanations and/or solutions:

1. With which does the trigonometric functions work with angles in c++?

a) Degrees

b) Radians

c) Both a & b

d) None of the mentioned

View Answer

Explanation:The trigonometric functions work with angles in radians rather than degrees.

2. Which header file is required for manipulation of math functions in c++?

a) cmath

b) maths

c) math

d) None of the mentioned

View Answer

Explanation:#include

3. How many macros are used by mathematical functions in the header file

a) 1

b) 2

c) 3

d) 4

View Answer

Explanation:There are three macros used in mathematical functions. They are HUGE_VAL, EDOM, ERANGE.

4. What is the output of this program?

`#include <stdio.h>`

`#include <math.h>`

int main ()

`{`

int param, result;

int n;

param = 8.0;

result = frexp (param , &n);

printf ("%d \n", param);

return 0;

`}`

a) 6

b) 7

c) 8

d) 9

View Answer

Explanation:In this program, We are breaking out the number by using the frexp function.

Output:

$ g++ math.cpp

$ a.out

8

5. What is the output of this program?

`#include <stdio.h>`

`#include <math.h>`

int main ()

`{`

double param, result;

param = 5.5;

result = log (param);

printf ("%lf", result );

return 0;

`}`

a) 5.5

b) 3.14

c) 1.704

d) None of the mentioned

View Answer

Explanation:In this program, We are finding out the log value of param by using param function.

Output:

$ g++ math1.cpp

$ a.out

1.704748

6. What is the output of this program?

`#include <stdio.h>`

`#include <math.h>`

int main ()

`{`

printf ("%lf", pow (7.0,3));

return 0;

`}`

a) 343

b) 343.00

c) 334

d) None of the mentioned

View Answer

Explanation:In this program, We are calculating the 7 power of 3 by using the powfunction. As we are using 7.0, it is producing the result in 343.00

Output:

$ g++ math2.cpp

$ a.out

343.000000

7. What is the output of this program?

`#include <stdio.h>`

`#include <math.h>`

int main ()

`{`

printf ("%lf\n", fmod (5.3, 2) );

printf ("%lf\n", fmod (18.5, 4.2) );

return 0;

`}`

a) 1.300

b) 1.700

c) Both a & b

d) None of the mentioned

View Answer

Explanation:In this program, We are finding the remainder of the given values by using fmod function.

Output:

$ g++ math3.cpp

$ a.out

1.300000

1.700000

8. What is the output of this program?

`#include <stdio.h>`

`#include <math.h>`

int main ()

`{`

printf ("%lf", fabs (-10.6) );

return 0;

`}`

a) 10

b) -10

c) 10.600000

d) None of the mentioned

View Answer

Explanation:In this program, We are finding the absolute value of -10.6 by using abs function.

Output:

$ g++ math4.cpp

$ a.out

10.600000

9. Which of the following mathematical function is overloaded in <complex>

and <valarray>?

a) cos

b) tan

c) sin

d) mod

View Answer

Explanation:None.

10. How many parameters are used in frexp function?

a) 1

b) 2

c) 3

d) 4

View Answer

Explanation:There are two parameters that are used in frexp function. They are floating point value to be computed and pointer to an int object.

**Sanfoundry Global Education & Learning Series – C++ Programming Language.**

Here’s the list of Best Reference Books in C++ Programming Language.

To practice all features of C++ programming language, __here is complete set on 1000+ Multiple Choice Questions and Answers on C++__.