Ad

Friday 12 July 2013

Algo#42: Multiply by 7

Multiply given number by 7 without using * operator. What we can do is, multiply given number by 8 and then subtract given number from result. Now problem reduce to multiply by 8 rather than 7. But we know to multiply any number with power of 2, we can use shift operator. 

Following is implementation of above problem in c language.





Please write comments if you find anything wrong or you want to add something more related to this topic.

No comments:

Post a Comment

Write your comment here.

Ad