Divide the number until it gets reduced to 1 if we are successfully able to reduce the number to 1 it means input string is power of two if in between an odd number appears at the end it means string is not divisible by two hence not a power of 2.
while ( len_str != 1 str [ len_str - 1 ] != '1' ) {