How will you multiply two numbers using BITWISE operators ?

Questions by jagdeessh

Showing Answers 1 - 1 of 1 Answers

Following code snippet would do the required action:

   int a,b,result;
   printf("nEnter the numbers to be multiplied :");
   while(b != 0)               // Iterate the loop till b==0
      if (b&01)               // Logical ANDing of the value of b with 01
         result=result+a; // Update the result with the new value of a.
      a<<=1;              // Left shifting the value contained in 'a' by 1.
      b>>=1;             // Right shifting the value contained in 'b' by 1.

Suresh Reddy.V.V

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Answer Question

Click here to Login / Register your free account

Send   Reset


Related Answered Questions


Related Open Questions