math.h
Completed
Read a positive number and print its square root, its cube (pow) and its floor and ceiling, each with 2 decimals.
Input
One positive decimal number.
Output
Four lines.
Example
Input
2
Output
1.41 8.00 2.00 2.00
Editor
C
Hints
#include <math.h> for sqrt, pow, floor and ceil.
Solution explanation
The math.h functions work on double values.
Show solution
#include <stdio.h>
#include <math.h>
int main() {
double x;
scanf("%lf", &x);
printf("%.2f\n", sqrt(x));
printf("%.2f\n", pow(x, 3));
printf("%.2f\n", floor(x));
printf("%.2f\n", ceil(x));
return 0;
}