Check if given number is perfect square | C ++ program for the above approach ; If ceil and floor are equal the number is a perfect square ; Driver Code
#include <iostream> NEW_LINE #include <math.h> NEW_LINE using namespace std ; void checkperfectsquare ( int n ) { if ( ceil ( ( double ) sqrt ( n ) ) == floor ( ( double ) sqrt ( n ) ) ) { cout << " perfect ▁ square " ; } else { cout << " not ▁ a ▁ perfect ▁ square " ; } } int main ( ) { int n = 49 ; checkperfectsquare ( n ) ; return 0 ; }