Examveda

The option that is necessary to compile a C program having math functions is . . . . . . . .

A. -lm

B. -ln

C. -lp

D. -lq

Answer: Option A

Solution (By Examveda Team)

This question is about compiling C programs that use mathematical functions. Let's break it down:

In C programming, when you want to use mathematical functions like sin(), cos(), sqrt(), and others, you need to link your program with a library called math.h. This library provides the definitions and implementations of these functions.

The correct option to compile your C program with math functions is:

Option A: -lm

This option tells the compiler to link your program with the math library (libm.so or libm.a).

Let's look at why the other options are incorrect:

Option B: -ln - This option is usually associated with the "ncurse" library, which is used for terminal-based user interfaces.
Option C: -lp - This option links your program with the "pthread" library, which is for working with threads.
Option D: -lq - This option is not a standard library link flag.

Therefore, to compile a C program that uses math functions, you need to use the -lm flag during compilation.

This Question Belongs to MySQL >> MySQL Miscellaneous

Join The Discussion

Related Questions on MySQL Miscellaneous