I am using Bode\'s formuala to calculate distance of nth planet from sun
dist = (4 + 3*(2^(n-2)))/10
If I calculate the distance this way,
The ^ operator, in C++ (and several other languages) means "exclusive or", not "raise to power".
C++ does not have a "raise to power" operator; you need to use the 2-argument function pow (you can #include the old C-generation , or #include and use std::pow), which returns a double; or, as other answers have suggested, for this special case you might use bit-shifting.