http://www.geeksforgeeks.org/multiply-number-10-without-using-multiplication-operator/
Given a number, the task is to multiply it with 10 without using multiplication operator?
A simple solution for this problem is to run a loop and add n with itself 10 times. Here we need to perform 10 operations.
A better solution is to use bit manipulation. We have to multiply n with 10 i.e; n*10, we can write this as n*(2+8) = n*2 + n*8 and since we are not allowed to use multiplication operator we can do this using left shift bitwise operator. So n*10 = n<<1 + n<<3.
A better solution is to use bit manipulation. We have to multiply n with 10 i.e; n*10, we can write this as n*(2+8) = n*2 + n*8 and since we are not allowed to use multiplication operator we can do this using left shift bitwise operator. So n*10 = n<<1 + n<<3.
int
multiplyTen(
int
n)
{
return
(n<<1) + (n<<3);
}