C Programming Multiple Choice Questions and Answers on Mathematical Functions for Freshers

https://www.computersprofessor.com/2018/01/c-programming-multiple-choice-questions_10.html
1. What is the output of this C code?
#include
#include
int main()
{
int i = 90;
printf("%f\n", sin(i));
return 0;
}
a) Compile time error
b) Undefined behaviour
c) 0.893997
d) 1.000000
b) Undefined behaviour
c) 0.893997
d) 1.000000
Answer: a
2. What is the output of this C code?
#include
#include
int main()
{
unsigned int i = -1;
printf("%f\n", fabs(i));
return 0;
}
a) Compile time error
b) 1
c) -1
d) None of the mentioned
b) 1
c) -1
d) None of the mentioned
Answer: d
3. function fabs defined math.h header file takes argument of type integer.
a) True
b) False
c) Depends on the implementation
d) Depends on the standard
Answer: b
4. log(x) function defined in math.h header file is
a) Natural base logarithm
b) Logarithm to the base 2
c) Logarithm to the base 10
d) None of the mentioned
Answer: a
5. What is the output of this C code?
#include
#include
int main()
{
int i = 10;
printf("%f\n", log10(i));
return 0;
}
a) Compile time error
b) 1.000000
c) 2.302585
d) None of the mentioned
b) 1.000000
c) 2.302585
d) None of the mentioned
Answer: b
6. What type of inputs are accepted by mathematical functions?
a) short
b) int
c) float
d) double
Answer: d
7. In linux, apart from including math header file, the program is successfully executed by which of the following?
a) cc filename.c
b) cc filename.c -lc
c) cc -math filename.c
d) cc -lm filename.c
Answer: d
8. Which of the following is not a valid mathematical function?
a) frexp(x);
b) atan2(x,y);
c) srand(x);
d) fmod(x);
Answer: d
9. Which of the following mathematical function requires 2 parameter for successful function call?
a) fmod();
b) div();
c) atan2();
d) all of the mentioned
Answer: d
10. Which mathematical function among the following does NOT require int parameters?
a) div(x, y);
b) srand(x);
c) sqrt(x);
d) all of the mentioned
Answer: c
11. sin(x) returns
a) sine of x where x is in radians
b) sine of x where x is in degree
c) cosine of x where x is in radians
d) cosine of x where x is in degree
Answer: a
12. cos(x) returns
a) sine of x where x is in radians
b) sine of x where x is in degree
c) cosine of x where x is in radians
d) cosine of x where x is in degree
Answer: c
13. What is the output of this C code?
#include
#include
void main()
{
int k = pow(2, 3);
printf("%d\n", k);
}
a) 9
b) 8
c) -1
d) 6
b) 8
c) -1
d) 6
Answer: b
14. What is the output of this C code?
#include
#include
void main()
{
int k = fabs(-87);
printf("%d\n", k);
}
a) -87
b) 87
c) 78
d) error
b) 87
c) 78
d) error
Answer: b
15. What is the output of this C code?
#include
#include
void main()
{
int k = sqrt(-4);
printf("%d\n", k);
}
a) -2
b) 2
c) Compile time error
d) NaN
b) 2
c) Compile time error
d) NaN
Answer: d
16. Which among the following mathematical function do not have a “double” return-type?
a) srand(x);
b) ceil(x);
c) floor(x);
d) both ceil(x); and floor(x);
Answer: a