Đề bài kiểm tra số chính phương.
Vì sao ở dòng code này lại sd Long double ở dòng 5 ạ? Em chưa hiểu lắm ạ mong mn giúp đỡ.
// CPP program to find if x is a
// perfect square.
#include <bits/stdc++.h>
using namespace std;
bool isPerfectSquare(long double x) //dòng này
{
// Find floating point value of
// square root of x.
if (x >= 0) {
long long sr = sqrt (x);
// if product of square root
//is equal, then
// return T/F
return (sr * sr == x);
}
// else return false if n<0
return false
}
int main()
{
long long x = 2500;
if (isPerfectSquare(x))
cout << "Yes";
else
cout << "No";
return 0;
}