Give a fast way to multiply a number by 7

Answer Posted / rupesh

There is a problem with
x=(x<<3)-x;
Suppose that x is stored in 8 bit format.
If x = 64, i.e. 2^6, then this won't work.
In general, if x is n-bit, and value of x > 2^(n-3), then
this won't work.

Is This Answer Correct ?    4 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;

603


There is a practice in coding to keep some code blocks in comment symbols than delete it when debugging. How this affect when debugging?

816


Can we declare variables anywhere in c?

573


How can you pass an array to a function by value?

597


Can static variables be declared in a header file?

612






Is there any demerits of using pointer?

621


How can you return multiple values from a function?

626


Write a program to print all permutations of a given string.

638


Explain modulus operator.

590


Can a pointer be static?

615


Describe newline escape sequence with a sample program?

647


What is bubble sort in c?

631


What is a memory leak? How to avoid it?

569


What is the best way to comment out a section of code that contains comments?

776


Which one would you prefer - a macro or a function?

598