Tuesday, 17 June 2014

C++ program to check whether the given number is perfect square or not


Here is a C++ program to check whether the given number is perfect square or not


 SOURCE CODE OUTPUT
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
       int num;
       float sqrnum;
       cout<<"Enter the value ";
       cin>>num;
       sqrnum=sqrt(num);
       if(sqrnum*sqrnum==num)
           cout<<"Given number is perfect square ";
       else
           cout<<"Given number is not perfect square";
       return 0;
}

Any questions regarding to program please write in comments.

No comments:

Post a Comment