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
What is the default value of local and global variables in c?
What is a struct c#?
How can you be sure that a program follows the ANSI C standard?
When is the “void” keyword used in a function?
What are qualifiers?
What is the difference between int main and void main?
explain what are pointers?
What is FIFO?
main() { printf("hello"); fork(); }
What is the g value paradox?
What is nested structure with example?
What's a good way to check for "close enough" floating-point equality?
Apart from dennis ritchie who the other person who contributed in design of c language.
What are variables c?
struct screen_pos{ int row, col } ;move_right(cursor)struct screen_pos *cursor;{ cursor.col++; } /* This statementhas a syntax error */What is the correct statement a) cursor.col = cursor.col + 1; b) col.cursor++; c) *cursor.col++; d) pointer