Function | #include | What It Does |
---|---|---|
sqrt() | math.h | Calculates the square root of a floating-point value |
pow() | math.h | Returns the result of a floating-point value raised to a certain power |
abs() | stdlib.h | Returns the absolute value (positive value) of an integer |
floor() | math.h | Rounds up a floating-point value to the next whole number (nonfractional) value |
ceil() | math.h | Rounds down a floating-point value to the next whole number |
#include <stdio.h> #include <math.h> int main() { float result,value; printf("Input a float value: "); scanf("%f",&value); result = sqrt(value); printf("The square root of %.2f is %.2fn", value,result); result = pow(value,3); printf("%.2f to the 3rd power is %.2fn", value,result); result = floor(value); printf("The floor of %.2f is %.2fn", value,result); result = ceil(value); printf("And the ceiling of %.2f is %.2fn", value,result); return(0); }
No comments:
Post a Comment