Perfect Cube | C ++ program to check whether the given number N is the perfect cube or not ; Function to check if a number is a perfect Cube or not ; Iterate from 1 - N ; Find the cube of every number ; Check if cube equals N or not ; Driver code ; Function call
. #include <bits/stdc++.h> NEW_LINE using namespace std ; void perfectCube ( int N ) { int cube ; for ( int i ; i <= N ; i ++ ) { cube = i * i * i ; if ( cube == N ) { cout << " Yes " ; return ; } else if ( cube > N ) { cout << " NO " ; return ; } } } int main ( ) { int N = 216 ; perfectCube ( N ) ; return 0 ; }