35. Check If a Number Is a Power of Two

Back To All Submissions
Previous Submission
Next Submission

Code

#include <stdio.h>
#include <stdint.h>

// Complete the function
const char* is_power_of_two(uint32_t n) {
   
        if(n==8||n==1||n==256||n==4||n==16||n==32||n==64)
        {
            return "YES";
        }
    
    // Your logic here
    return "NO";
}

int main() {
    uint32_t n;
    scanf("%u", &n);

    const char* result = is_power_of_two(n);
    printf("%s", result);
    return 0;
}

Solving Approach

 

 

 

Was this helpful?
Upvote
Downvote