In this tutorial we are going to see new program which is to **Multiply two numbers without using multiplication operator**.

Normally to perform multiplication of numbers we use Multiply operator but in this program we implement c program to Multiply two numbers without using multiplication operator.

Multiply two numbers without using multiplication operator is easy program which mostly asked in interviews or exams.

**Logic to multiply number without using multiplication operator**

We know that how the multiplication is done the first number get added second number of times. Using this trick we implement program.

**Example :-**

Multiply two numbers

First number = 5 and second number = 4

We Multiply two numbers by adding first number , second number of times.

i.e. answer = 5 + 5 + 5 + 5

answer = 20

**Topic you need to know from c**

1. looping in c (for loop , while , do while)

2. Basic input and output in c

**Algorithm to to multiply number without using multiplication operator**

1. start

2. Declare variables a,b , c, i=1

3. Take two number input from user a and b.

4. Use for loop iterate i second number i < = b

5. If condition true add first number and store in c. c =+ b

6. If condition false skip loop

7. Print multiplication c.

8.End.

**Program to multiply number without using multiplication operator**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
#include<stdio.h> void main() { //declare variables int first, second, mul, i; // take two numbers from users printf(" Enter first number :\n"); scanf ("%d",&first); printf ("Enter second number :\n"); scanf ("%d",&second); //main logic begins mul = 0; for(i=1;i<=second;i++) { mul= mul+first; ; } printf("\n multiplication of %d and %d is = %d ", first , second , mul); } |

**Output :-**

**Explanation :-**

**1. First start with main where program execution starts.**

**2. Declare the variables**

first => to store first number

second => to store second number

mul => to store multiplication value

i => temporary variable

**3. Take a input from user first number and second number .for example first = 5 and second = 2**

**4. Initialize mul = 0 the initial value.**

**5. Next we write main logic that is to add number second number of times.**

**At first iteration** i = 1 , i initialized to 1 and condition checked i <= second i.e. 1 <= 2 this condition become true and enters in block and statement in block executed.

mul =+ first ;

=> mul = mul + first

=> mul = 0 + 5

=> mul = 5

After this value of i get incremented.

**At second iteration** i = 2 and condition checked i <= 2 => i <= 2 this condition get true again the loop block get executed.

mul =+ first ;

=> mul = mul + first

=> mul = 5 + 5

=> mul = 10

After this value of i get incremented.

**At third iteration** i = 3 , and condition checked i <= 2 => 3 <=2 now the condition get false and execution come out of the loop.

**6. Print multiplication of numbers .**

## Leave a Reply