# Program to check that number is perfect square or not

## Program to check that number is perfect square or not : –

**Method 1:-** 1. find the square root of the number .

2. multiple the square root two times .

3. check (sq*sq)==number then it is perfect square

4. otherwise not a perfect square

**Code in C++:-**

#include<bits/stdc++.h> using namespace std; int main() { int n; cout<<"Enter a number\n"; cin>>n; // checking for perfect square long long sq=sqrt(n); if(sq*sq==n) cout<<n<<" is a perfect square"<<endl; else cout<<n<<" is not a perfect square"<<endl; return 0; }

**Output:- **

Enter a number 6 6 is not a perfect square

**Method 2: –**

- in this method we will use the ceil and floor .
- if ceil(sqrt (n))==floor(sqrt(n)) then number is perfect square.

**Code in C++:-**

#include<bits/stdc++.h> using namespace std; int main() { int n; cout<<"Enter a number\n"; cin>>n; // checking for perfect square double sq=sqrt(n); cout<<sq<<endl; if(ceil(sq)==floor(sq)) cout<<n<<" is a perfect square"<<endl; else cout<<n<<" is not a perfect square"<<endl; return 0; }

python code:-

import math n=int(input()) x=int(math.sqrt(n)) if (x*x)==n: print(n,"is a perfect square") else: print(n,"is not a perfect square")

output:-

49 49 is a perfect square

Program to check that number is perfect square or not

**Also check this:-**

__codechef problems:-__- Primary test
- Sum or difference
- point and line

__Wipro :-__

- Update the booking ID | Wipro previous year question paper solution
- Pages in PDF
- Find the location id
- Find the odd digits
- Find the Product ID

__Infytq :-__

__Key Points;-__

__Hackerrank:-__

- Python : missing characters : hackerrank solution
- Python : string transformation | Hackerrank solution
- Active Traders certification test problem | Hackerrank Solution
- Usernames changes certification test problem | Hackerrank Solution
- string Representation of objects certification test hackerrank solution
- Average Function | hackerrank certification problem solution

__C-tutorial:-__

- Micros in C
- Pointer in c
- Function declaration
- Types of user define function
- return type of function
- 2D array

__See more:-__

- c program to convert specified days into years weeks and days

- Print Reverse Hollow Pyramid
- Update the booking ID | Wipro previous year question paper
- Pages in PDF | Wipro previous year question paper
- Sparse Matrix in data structure
- Find the location ID | Wipro previous year Coding question
- find the odd digits | Wipro Coding question
- Find the product id | Wipro Coding question
- Difference between static and dynamic memory allocation
- What is asymptotic Notation