Tuesday, 7 March 2017

Geeksforgeeks Solution For " Check if a number is Perfect Square "

GeeksforGeeks Solution For School Domain .Below You Can Find The Solution Of Basic ,Easy ,Medium ,Hard .You Can Also Direct Submit Your Solution to Geeksforgeeks Same Problem .You Need to login then you can submit you answers 

Problem :- Given a natural number n, print 1 if it is perfect square else 0.

Submit Your Solution :- Click Here 


Solution :-

#include <iostream>
using namespace std;
int main() 
{
int t1;
cin>>t1;
while(t1--)
{
  int n,x,i,j,flag=0;
  cin>>n;
  
  for(i=1;i<320;i++)
  {
      j=i*i;
      if(j==n)
      {
      cout<<"1"<<endl;
      flag=1;
      }
  }    if(flag!=1)
      cout<<"0"<<endl;
}    

return 0;
}

Output:-

Geeksforgeeks Solution For " Check if a number is Perfect Square "

No comments:
Write comments

Recommended Posts × +