Question

in C why do you had to compile the code with the flag -lm at the...

in C why do you had to compile the code with the

flag -lm

at the end. Why is it and what does this flag indicate?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

-l is used to link static library

-l<library name>

Reason for adding -lm because m stands for math library which is already provided by C compiler and -l is used to link that library so that we can access common math functions like pow (power) , sin (Sine of angle) etc

Hence -lm flag is used.

Similary lets say we have created a library name with name as util , so we can use -lutil to link our library


PLEASE COMMENT if there is any concern/doubts

Add a comment
Know the answer?
Add Answer to:
in C why do you had to compile the code with the flag -lm at the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The following code will not compile. Fix it by inserting one line of code. Do not...

    The following code will not compile. Fix it by inserting one line of code. Do not change anything else. Hint: copy and paste the code below into your answer box, then make the required addition. Also include a comment indicating the line of code that you inserted, and why that line of code is required include <iostream> using namespace std int mainO cout <<"The word of the day is: sayword 0 return 0 void sayWordO f cout くく "WORD!";

  • Will the following code compile? If not, why not? Assume it is using the standard namespaces,...

    Will the following code compile? If not, why not? Assume it is using the standard namespaces, includes all necessary libraries and has a defined class called "MyClass" with a default constructor. vector <MyClass> vec; MyClass myClass; vec.push_back(myClass); Options: 1. No, vectors must push back data types, not instances of a data type 2. no, space was never allocated for the vector 3. no, you can not use a user defined data type at the data type for a vector 4....

  • 10. Does the following code compile? Does it run? Is there any problem with the code?...

    10. Does the following code compile? Does it run? Is there any problem with the code? If yes, how do you fix it? 1. #include < iostream > 2. using namespace std; 4 class Computer int Id; 7. public: Computer(int id) this -Id- id; ) void process() cout << "Computer::process()"; 9 10. H; 12. class Employee 13. 14. 15. public: 16 Computer* c; Employee )cnew Computer (123); 17.Employee() C 18. 19. 20 21. 22. ^; 23. 24. int main(){ 25....

  • Problem 1: (20 marks) Part 1: (15 points) Compile the RISC-V assembly code for the following C co...

    please code using risc-v language and make it as simple as possible Problem 1: (20 marks) Part 1: (15 points) Compile the RISC-V assembly code for the following C code. Assume that n and k are passed in x3 and x4 respectively. Values n and k are initialized to 14 and 14. Assume that result returned in register fl and that double precision numbers are used. After you are done store the result in address: 12(x3). Are you allowed to?...

  • I need help answering the following: Why does the following code not compile? List<Integer> intList =...

    I need help answering the following: Why does the following code not compile? List<Integer> intList = new ArrayList<>(); List<Number> numList = intList; a). The types list and ArrayList are different b). Integer is not a subclass of Number. c). List<Integer> is not a subclass of List<Number> d). There is a syntax error. Which of the following statements about Java I/O streams is true? a). I/O streams are only useful for reading to / writing from files on disk b). Character...

  • Why do we no longer study the IS-LM model in economics? (i.e. why is it now...

    Why do we no longer study the IS-LM model in economics? (i.e. why is it now considered the IS model instead?)

  • 6. (Short answer) The C++ code below is very close to working, but, as written, won't...

    6. (Short answer) The C++ code below is very close to working, but, as written, won't compile. When trying to compile, the compiler generates a number of errors similar to "cout' was not declared in this scope." Respond to the prompts below about the code.(20 points, 5 points each) #include <iostream> void FindMax(int a, int b, int& max) { if (a > b) max = a; else { max = b; } int main() { int num1 = 0; int...

  • Compile the following C code into PICmicro Assembly Language Unsigned char a, b, c a 16...

    Compile the following C code into PICmicro Assembly Language Unsigned char a, b, c a 16 b 64 c= a + b

  • 1) Compile thread2.c (remember the -lpthread flag). Run it numerous times, and notice the output usually...

    1) Compile thread2.c (remember the -lpthread flag). Run it numerous times, and notice the output usually differs. a) Why is the variable myglobal usually not 40? Be specific, be precise. b) In what special case would myglobal be 40? Be specific, be precise. #include <pthread.h> #include <stdlib.h> #include <unistd.h> #include <stdio.h> #include <fcntl.h> /* Purpose: Use 2 threads to increment myglobal exactly 40 times in total. Compile: using -pthread option */ int myglobal = 0; void *thread_function(void *arg) {   ...

  • txtlnput is a textbox. What does the following code do? txtInput= "; O Clears the contents...

    txtlnput is a textbox. What does the following code do? txtInput= "; O Clears the contents of txtInput The code does not compile None of the above

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT