## Introduction

In this article, we will write a C program to multiply two numbers using the plus operator. To reach this goal, we need to have information about the loops in C.

A loop statement allows us to execute a statement or group of statements multiple times.

Given two numbers as input from the user, we have to multiply them without using arithmetic operators like +. For this program, we are going to perform the multiplication of two numbers by repetitive addition. In other words, X * Y is the same as X + X + X … (Y times).

You can also read about __dynamic array in c__ and __C Static Function____.__

**Also see - **Strong number in c

## Using the ‘for’ loop

A 'for' loop can be understood as a control structure that is in repetition, which allows us to efficiently write a loop which needs to be executed a specific number of times.

So, let us see how we can multiply two numbers using the plus operator using the ‘for’ loop.

Let’s see the algorithm first.

### Problem Statement

The problem statement is that we are given two integers, X and Y. We have to multiply X and Y using the plus operator.

Sample Input

5 6 |

Sample Output:

30 |

Explanation:

We are going to add X+X+X…(Y times). So, we will add 5 to itself 6 times. 5+5+5+5+5+5 = 30 |

**Algorithm**

- Take two numbers (X, Y) as inputs from the user.
- Take an integer type variable for storing the result.
- Initialize result with 0.
- Calculate the result using the ‘for’ loop by adding the number to the result.
- Display the result.

**Implementation**

```
#include <stdio.h>
int main()
{
int x, y;
int result= 0, i;
printf("Enter the first number: ");
scanf("%d",&x);
printf("\nEnter the second number: ");
scanf("%d",&y);
for(i=1;i<=y;i++) {
result += x;
}
printf("\nMultiplication of %d and %d is: %d\n" , x, y, result);
return 0;
}
```

Output:

you can practice by yourself with the help of an online editor.

### Complexity Analysis

**Time Complexity: **O(X) or O(Y), where X and Y are the first and second number respectively.

**Space Complexity: **Constant space.

Also Read, __Binary to Hex Converter____ __and __Tribonacci Series__

Must Read __what is storage class in c__