Print out the square root of a given integer with only two decimal places.
#include <iostream>
#include <math.h>
#include <iomanip>
int main()
{
double value = 0.0;
std::cout << "Enter value: ";
std::cin >> value;
double result = sqrt(value);
std::cout << std::fixed;
std::cout << std::setprecision(2);
std::cout << "Square root is: " << result << std::endl;
return 0;
}
Comments
Leave a comment