cmath Functions
Completed
Read a decimal x ≥ 0. Print sqrt(x), pow(x, 3), round(x) and floor(x), each with 2 decimals.
Input
One number.
Output
Four lines.
Example
Input
2
Output
1.41 8.00 2.00 2.00
Editor
C++
Hints
#include <cmath>.
Solution explanation
Setting fixed and the precision once applies to every later number.
Show solution
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main() {
double x;
cin >> x;
cout << fixed << setprecision(2);
cout << sqrt(x) << "\n" << pow(x, 3) << "\n" << round(x) << "\n" << floor(x) << "\n";
return 0;
}