Learn Computer Science programming - C# and C++ Algorithms

 
Multiplication without the operator

Multiply two numbers without using the * operator.
Code
 
Multiplying a number by 2 without using the * operator

Note that shifting right is equivalent to dividing by powers of 2 and shifting left is equivalent to multiplying by powers of 2. 

Example: 
    char n = 5;       // 00000101 binary 
    a = n << 1;       // 00001010 == 0x0A == 10 
    b = n >> 1;       // 00000010 == 0x02 == 2
    c = n << 4;       // 01010000 == 0x50 == 80

Multiply by 8, 16, 7, 2, or 15 without using multiplication
Multiply by 15

char n=5;
b= n << 4 // Multiplied by 16
b=b-n = // Subtract n to get multiplication by 15