Is there any predefined function in c++ to check whether the number is square of any number and same for the cube..
For perfect square you can also do:
if(sqrt(n)==floor(sqrt(n))) return true; else return false;
For perfect cube you can:
if(cbrt(n)==floor(cbrt(n))) return true; else return false;
Hope this helps.