Series: Subject: Topic:
Question: 456 of 828

How will you multiply two numbers using BITWISE operators ?

Asked by: jagdeessh | Member Since Jul-2006 | Asked on: Aug 24th, 2006

View all questions by jagdeessh

Showing Answers 1 - 1 of 1 Answers

Answered On : Aug 29th, 2006

View all answers by vvsureshreddy

Following code snippet would do the required action:#include<stdio.h>main(){   int a,b,result;   printf("nEnter the numbers to be multiplied :");   scanf("%d%d",&a,&b);   result=0;   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.   }   printf("nResult:%d",result);}Suresh Reddy.V.V

Yes  1 User has rated as useful.
Login to rate this answer.

Give your answer:

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

Related Open Questions



twitter fb Linkedin GPlus RSS


Interview Question

 Ask Interview Question?


Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.