int findComplement(int num){ int sum =0,pst=0; while(num){ if ((num & 1) == 0) { sum += pow(2,pst); } num >>= 1; pst++; } return sum; }