Any help would be greatly appreciated

Write a program, that uses the following algorithm, as part of a function, to determine if a number n ≥ 2 is a power of 2, such as 21 = 2, 23 = 8 or 210 = 1024, but not 24 - 3 = 13. To do this, you need to repeatedly attempt to divide n by 2k, where k = 1, 2, 3, ... until n is either found to be divisible by 2k or 2k > n. The function returns true if n is a power of 2 and false otherwise. The result, either yes or no, is output to the screen. The value n, is entered, via the keyboard, by the user. Your submission should include a screenshot of the execution of the program using each of the values n = 2, 3, 4, 5, 10, 16, 35, 101 and 128.
Please note, that this is not a homework site.
We won't do your homework for you.
The purpose of homework is that you learn by doing.
However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.


We didn't see your attempts to solve this problem yourself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again.
Can you break it down it terms of a sort of psuedo code?

For instance,

Pseudo code:

decalre vairable x
decalre variable y
declare variable sum

main function start

sum = variable x + varible y

display sum

stop

Proper code:

int x = 2;
int y = 2;
int sum;

int main () {

sum = x + y;

cout << sum;

}

I would really any kind of help. I'm not loking for an acural answer.
Last edited on
Topic archived. No new replies allowed.