45 int result = n & (n - 1);
60 std::cout <<
"First case testing... \n";
62 std::cout <<
"\nPassed!\n";
64 std::cout <<
"Second case testing... \n";
66 std::cout <<
"\nPassed!\n";
68 std::cout <<
"Third case testing... \n";
70 std::cout <<
"\nPassed!\n";
72 std::cout <<
"\nAll test cases have successfully passed!\n";
82 std::cout <<
"Enter a number " << std::endl;
88 std::cout <<
"Yes, the number " << n <<
" is a power of 2\n";
91 std::cout <<
"No, the number " << n <<
" is not a power of 2\n";
int power_of_two(int n)
This function finds whether a number is power of 2 or not.
static void test()
Self-test implementations.
void user_input_test()
Take user input in the test cases (optional; currently commented)