A program to explain MATH HANDLING FUNCTIONS
C Programming Language 119
- Write a program to explain MATH HANDLING FUNCTIONS
Program
#include <stdio.h>
#include <math.h>
// If you get an error compile it using `-lm` flag
// `gcc input.c -lm -o output && output
// Reference: https://www.codeproject.com/Questions/137889/undefined-reference-to-cos
void main()
{
printf("Square = %f\n", pow(4, 2));
printf("Square Root = %f\n", sqrt(4));
printf("Ceil = %f\n", ceil(4.32));
printf("Floor = %f\n", floor(4.32));
printf("cosine = %f\n", cos(0));
printf("sine = %f\n", sin(0));
printf("\n");
}
Result
Square = 16.000000
Square Root = 2.000000
Ceil = 5.000000
Floor = 4.000000
cosine = 1.000000
sine = 0.000000
Last Updated on
Comments