Qualcomm Interview Question

white board: write a function that determines if a given variable is a power of 2 or not

Interview Answers

Anonymous

Nov 28, 2019

int check_pwr_of_2(int num) { if((num & (num-1)) == 0) { return 1; } return 0; }

Anonymous

Nov 28, 2019

int check_pwr_of_2(int num) { if((num & (num-1)) == 0) { return 1; } return 0; }