07-25-2023, 01:29 PM
To use functions from external libraries, you need to link them during the compilation process.
// Compile with math library
// gcc main.c -lm -o main
#include <stdio.h>
#include <math.h>
int main() {
double result = pow(2, 3);
printf("2^3 = %.2f\n", result); // Output: 2^3 = 8.00
return 0;
}
// Compile with math library
// gcc main.c -lm -o main
#include <stdio.h>
#include <math.h>
int main() {
double result = pow(2, 3);
printf("2^3 = %.2f\n", result); // Output: 2^3 = 8.00
return 0;
}