3 What steps are required to use functions for the standard C, standard C++, and the math library? Use an example C/C++ program to illustrate your answer.
What will be an ideal response?
To use the features of standard C library no special compiler option is required. eg:
```
// use this program as a test
// the file is called hello.c
#include
int main()
{
printf("Hello World\n");
return 0;
}
To compile the above program use the following command:
gcc hello.c -o hello
To use the features of standard C++ a compiler option is required. eg:
// use this program as a test
// the file is called hello.cpp
#include
int main()
{
cout << "Hello World\n";
return 0;
}
To compile the above program use the following command:
gcc -lg++ -o hello hello.cpp
or
g++ -o hello hello.cpp
To use the math library a compiler option is required:
// use this program as a test
// the file is called power.c
#include
#include
int main()
{
printf("The square of 5 is %d",pow(5,2));
return 0;
}
To compile the above program use the following command:
gcc -lm -o power power.c
```
You might also like to view...
What two strategies are employed by the BSIMM security testing practice?
Fill in the blank(s) with the appropriate word(s).
By default, the tabs on a JTabbedPane appear at the:
a. top. b. bottom. c. left. d. right.
Which is true about web-based application software?
A) It is installed by the computer manufacturer. B) It is always free. C) It is stored completely on a web server instead of your hard drive. D) It does not need an Internet connection.
When small manual formatting changes are made, Word will automatically update the style
Indicate whether the statement is true or false