Give a fast way to multiply a number by 7
Answer Posted / anonymous
The easiest way is to relate the number to be multiplied
by, to a power of 2. Then a corresponding number of left
shifts to that power with an addition or subtraction would
give the desired result.
In this case, 7 can be written as 2^3 - 1 or 8 - 1.
Therefore, shift the number to the left thrice which would
multiply it by 8. Then subtract the original. You can also
do this as
4 + 2 + 1 = 2^2 + 2^1 + 1
Is This Answer Correct ? | 20 Yes | 6 No |
Post New Answer View All Answers
A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream
What is a memory leak? How to avoid it?
What is the use of a semicolon (;) at the end of every program statement?
An integer that indentifies the position of a data item in a sequence of data items a) value b) number c) index d) all of the above
What language is windows 1.0 written?
Why do we use pointer to pointer in c?
What are the 4 types of programming language?
Is c compiled or interpreted?
What are global variables and how do you declare them?
i have to apply for the rbi for the post of officers. i need to know abt the entrance questions whether it may be aps or techinical....
How are Structure passing and returning implemented by the complier?
What is difference between array and pointer in c?
Explain what is the benefit of using enum to declare a constant?
What is the difference between exit() and _exit() function in c?
hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .