Which option is necessary to compile a C program havin math functions?
A. -lm
B. -ln
C. -lp
D. -lq
Answer: Option A
Solution (By Examveda Team)
This question is asking about how to link the math library in a C program. The math library is a collection of pre-written functions for doing mathematical operations like calculating square roots, trigonometric functions (like sine, cosine), logarithms, and more.To use these functions in your C program, you need to tell the compiler where to find them. This is done by adding a special flag to the compilation command.
The correct answer is Option A: -lm. This flag tells the compiler to link the math library (which is usually named "libm.so" or "libm.a").
The other options are incorrect because they don't refer to the math library:
* Option B: -ln is used to link the network library.
* Option C: -lp is used to link the standard C library (libc).
* Option D: -lq is not a standard linker flag in most systems.
Example:
If your C program is named "myprogram.c" , you would compile it with the math library using the following command:
``` gcc myprogram.c -lm -o myprogram ```
This command compiles the "myprogram.c" file, links the math library, and creates an executable file named "myprogram".
Related Questions on MySQL Miscellaneous
How is communication established with MySQL?
A. SQL
B. Network calls
C. A programming language like C++
D. APIs
Which type of database management system is MySQL?
A. Object-oriented
B. Hierarchical
C. Relational
D. Network

Join The Discussion