Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to find if number is perfect square

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
  int n;
  double root;
  cout << "Enter The number : ";
  cin>>n;
  root = sqrt(n);
  if (pow(root + 0.5,2) == n) 
  {
    cout << "Perfect Square" << endl;
  }
  else
  {
   cout << "Not Perfect" << endl;
  }
  return 0;
}
Source by djangocentral.com #
 
PREVIOUS NEXT
Tagged: #find #number #perfect #square
ADD COMMENT
Topic
Name
9+9 =