C Program to Multiply Two Numbers using the Addition Operator

Write a program to multiply given two numbers using the Addition Operator.

Input :

Two numbers as space-separated.
1<=input<= 10^15.

Constraint:
Should not use Operators ‘ * ‘.

Output:
 Print the result

sample Input 1

3 4

Sample Output 1

12

Code:

#include<stdio.h>

int main()
{
long long int i,n,m,sum=0;
scanf("%lld%lld",&n,&m);

for(i=1;i<=m;i++){
   sum=sum+n;
}
printf("%lld",sum);

return 0;
}
Code language: C/AL (cal)

Leave a Comment