C Program to multiply two numbers without using * operator
Get two inputs num1 and num2, compute the product of num1 and num2 without using * operator
Sample Input 1:
5 6
Sample Output 1:
30
Program or Solution
#include<stdio.h>
int main()
{
int num1,num2,product=0;
printf("Enter two numbers:");
scanf("%d %d",&num1,&num2);
while(num2>0)
{
product=product+num1;
num2--;
}
printf("The product is :%d",product);
return 0;
}
Program Explanation
4*5 = 4+4+4+4+4 Add the 4 with product for 5 times using while statement.