How to multiply two numbers without using the multiple operator (*) in C

1 Answer

0 votes
#include <stdio.h>     

int main(int argc, char **argv)
{	
	int a = 3, b = 9, mul = 0;
 
	// mul = a * b
 
	for (int i = 1; i <= a; i++)
		 mul = mul + b;
 
    printf("%d * %d = %d", a, b, mul);
 
    return 0;
}


/*
run:
  
3 * 9 = 27

*/

 



answered Mar 21, 2016 by avibootz
...