3. Program to demonstrate library functions in math.
#include <stdio.h> // For input/output functions like printf
#include <math.h> // For mathematical functions
int main() {
double num = 9.0;
double base = 2.0;
double exponent = 3.0;
double angle_degrees = 45.0;
double val_ceil_floor = 3.7;
// Square Root function: sqrt()
printf("Square root of %.2lf: %.2lf\n", num, sqrt(num));
// Power function: pow()
printf("%.2lf raised to the power of %.2lf: %.2lf\n", base, exponent, pow(base, exponent));
// Ceiling function: ceil() - rounds up
printf("Ceiling of %.1lf: %.1lf\n", val_ceil_floor, ceil(val_ceil_floor));
// Floor function: floor() - rounds down
printf("Floor of %.1lf: %.1lf\n", val_ceil_floor, floor(val_ceil_floor));
// Sine function: sin() - takes radians, convert degrees to radians using M_PI
double angle_radians = angle_degrees * (M_PI / 180.0); // M_PI is a macro in math.h
printf("Sine of %.0lf degrees: %.2lf\n", angle_degrees, sin(angle_radians));
// Absolute value function: fabs() for double
double negative_val = -10.5;
printf("Absolute value of %.1lf: %.1lf\n", negative_val, fabs(negative_val));
// Logarithm (natural log): log()
printf("Natural logarithm of %.2lf: %.2lf\n", num, log(num));
// Exponential function: exp() - e raised to the power of x
printf("e raised to the power of %.2lf: %.2lf\n", base, exp(base));
return 0;
}