C Program to find Product of 2 Numbers using Recursion

C program to find product of 2 numbers using recursion: This C program finds the product of two numbers without using the multiplication operator (*). The source code of the program and output are given below.

C program to find product of 2 numbers using recursion

/* Aim: C Program to find Product of 2 Numbers using Recursion */

#include<stdio.h>

int product(int, int);

int main()
{

	int number_1,number_2, result;

	printf("\n Enter two numbers to find their product:- ");
	scanf(" %d%d", &number_1, &number_2);

	result = product(number_1, number_2);

	printf("\n Product of %d and %d is %d \n", number_1, number_2, result);

	return 0;

}

int product(int number_1, int number_2)
{

	if(number_1<number_2)
	{
		return product(number_2, number_1);
	}
	else if(number_2 != 0)
	{
		return (number_1 + product(number_1, number_2 - 1));
	}
	else
	{
		return 0;
	}
}

/* Output of above code:-

Enter two numbers to find their product:- 110 240
Product of 110 and 240 is 26400

*/
Get This Program: