↳
Made no mistakes on this question, but had done similar things before
↳
//reverses bit between two indices of a number. #include using namespace std; int main() { unsigned int no=90,i=2,j=6,tmp=0,tmp1=0; tmp=no>>i; cout>1; } cout>1; if(x=i) tmp=tmp|0; else tmp=tmp|0x80000000; } cout< Less
↳
#include main(int arg, char *argv[]) { unsigned char num, hi_indx, lo_indx, mask, num_tmp, mask_c, num_rv, iter,i; num = atoi(argv[1]); hi_indx = atoi(argv[2]); lo_indx = atoi(argv[3]); mask = ((0xFF > (7-hi_indx+lo_indx); mask = (mask << lo_indx); mask_c = ~mask; num_tmp = num & mask_c; printf("%x %d %d %x",num, hi_indx, lo_indx, mask); num_rv = 0x0; iter = hi_indx-lo_indx+1; i = 0; while(i<=iter) { int flg; flg=(num & (1<<(i+lo_indx)))?1:0; if(flg) num_rv=num_rv|(1<<(hi_indx-i)); i++; } num = num_rv | num_tmp; printf("\nnum=%x ",num); } Less
↳
a=a^b b=b^a a=a^b
↳
but it should say swap two integers! because this XOR won't work with float for example Less
↳
This works for floats: a = a+b b = a-b a = a-b But you might overflow on a+b. Less
↳
25 Pins
↳
Is that even a relevant question ? :)
↳
Why does it matter as long as you know how to use the ICD?
↳
The analog and min hand overlap once each hour so the next overlap after 3:00 would be 3:16 and some change. Sanity check: 16 minutes should be between the 3:00 and 4:00 on the clock, which is true. Math: Hour hand gets an equation like 3 + (1/60)*minutes, since the hour hand starts at 3 and every minute it increases by 1/60th of an hour. The minute hand gets 12*(1/60) * minutes since in 60 minutes it goes around the 12 hours of the clock. So 3+(1/60)x = (12/60)x gives you 180/11 or about 16. Less
↳
1) hour = min / 12 deg 2) min = hour + hour(initial) = hour + 90 deg 1=>2 and solving gives 98.18 deg. Converting back into time format gives 3:16:22. Less
↳
you should keep the same units: Hour hand: starts at 15 min so 15 min + 5 min/hr*t Min hand: 60 min/hr 15 min + 5 min/hr * t = 60 min/hr 15 min = 55 min/hr * t 15/55 = .2727 hr .2727 hr * 60 min/hr = 16.3636 min = 16 min 21.8182 sec Less
↳
It's a Microsoft interview question to get you to think.
↳
Hi, is there any technical question? Thanks
↳
Depends on who interviews you. They might write some C code up on a whiteboard and you get to tell them what it does and or what is wrong with it. 2nd Interview is usually to see if you will make a good fit within the environment/culture of the team(s). As long as you can show that you can think or have a basic understanding, all is good. Less
↳
return (num != 0) && ((num & (num - 1)) == 0);
↳
return((num!=0) && ((num & (-1-num))==0))
↳
num = (num & (~(1 << 11 | 1 << 12))) | (given & (1 << 11 | 1 << 12)); Less
↳
num = (num & (~(3 << 12))) | (3 & given << 12 ));
↳
num ^= (Math.Pow(2, 11) + Math.Pow(2, 12))