Find the Next perfect square greater than a given number | C ++ implementation of above approach ; Function to find the next perfect square ; Driver Code
#include <iostream> NEW_LINE #include <cmath> NEW_LINE using namespace std ; int nextPerfectSquare ( int N ) { int nextN = floor ( sqrt ( N ) ) + 1 ; return nextN * nextN ; } int main ( ) { int n = 35 ; cout << nextPerfectSquare ( n ) ; return 0 ; }