## Interview Question

- 0of 0 votes
How can i multiply and divide with only using bit shifting and adding?

eg. multiply a no with 46.

**Country:**India

#include<stdio.h>

int main()

{

int i,output=0,mask=1,min,max;

printf("enter two no.'s);

scanf("%d%d",&min,&max);

if(min>max)

{

i=min;

min=max;

max=i;

}

for(i=1;mask<=min;i++,mask=mask*2,max<<=1) if(min&mask) output+=max;

printf("%d",output);

}

//Complexity= no. of bits in lesser number

46=32+8+4+2

- Aashish August 01, 2012n<<5 + n<<3 + n<<2 + n<<1