Problem statement
Write a program which take two numbers as input from a user and multiple each other without using multiplication operator. To multiply two numbers use addition or plus(+) operator.
Program of multiplication
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#include<stdio.h> int main() { int i=1,num1=0,num2=0,add=0; printf("Enter the two numbers: \n"); scanf("%d%d",&num1,&num2); while(i <= num2) { add=add+num1; i++; } printf("Multiplication of %d and %d is %d",num1,num2,add); } |
Output
1 2 3 |
Enter the two numbers: 2 3 Multiplication of 2 and 3 is 6 |
This program read two numbers and calculate multiplication using arithmetic plus (+) operator. We do not use multiplication operator(*) to multiply the numbers.