Skip to content

Commit

Permalink
Merge pull request #27 from harshbhut42/perfect_square
Browse files Browse the repository at this point in the history
Checks perfect square
  • Loading branch information
ambujraj authored Oct 1, 2018
2 parents 0b85a06 + 3f1b5bd commit 55a2bbd
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions prefect_square/perfect_square.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <bits/stdc++.h>
using namespace std;

bool isSqrt(long double n)
{
if(n<=0)
return false;
if(ceil(sqrt(n)) == floor(sqrt(n)) )
return true;
return false;
}

int main() {

ios_base::sync_with_stdio(false);
long double n = 1000000;


if(isSqrt(n))
cout << fixed << setprecision(2) << n << " Is perfect square\n";
else
cout << fixed << setprecision(2) << n << " Is not perfect square\n";


return 0;
}

0 comments on commit 55a2bbd

Please sign in to comment.