Math functions)

everyone is going to employ their C language programming skills to help pilot a rocket safely across space and into orbit around Titan. No, it’s more likely that you’ll attempt something far more down-to-earth. Either way, the work will most likely be done by employing math functions.
Function#includeWhat It Does
sqrt()math.hCalculates the square root of a floating-point value
pow()math.hReturns the result of a floating-point value raised to a
certain power
abs()stdlib.hReturns the absolute value (positive value) of an integer
floor()math.hRounds up a floating-point value to the next whole number
(nonfractional) value
ceil()math.hRounds down a floating-point value to the next whole
number
All the functions listed, save for the abs() function, deal with floating-point values. The abs() function works only with integers.

MATH MANIA MANGLED
#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