You've learned in the past lessons on how to use square root functions, right? Then let's take your knowledge to the test. Print out the square root of a given integer with only two decimal places.
Ready, solve, and go!
Input
A line containing an integer.
4
Output
A line containing a decimal with two decimal places.
2.00
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main(void){
int n;
cin>>n;
double sqrtn=sqrt(n*1.0);
cout<<fixed<<setprecision(2)<<sqrtn<<"\n\n";
system("pause");
return 0;
}
Comments
Leave a comment