0% found this document useful (0 votes)
7 views2 pages

Dsu Pr18 Main

Uploaded by

vedantwalanj18
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Dsu Pr18 Main

Uploaded by

vedantwalanj18
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Program to perform multiplication of two numbers using recursion

/*_________________Name: Vedant Walanj_______________*/


/*_________________Roll no:960______________________*/
/*_________________Branch: SYCO____________________*/
/*_________________Subject: DSU__________________*/
/*_________________Practical no:18__________________*/
/*__program to perform multiplication of two numbers using recursion__*/
/*_________________Date:26/9/24____________________*/

#include <stdio.h>
int multiply(int a, int b) {
if (b == 0) {
return 0;
} else if (b > 0) {
return a + multiply(a, b - 1);
} else {
return -multiply(a, -b);
}
}
int main() {
int num1, num2, result;

printf("Enter first number: ");


scanf("%d", &num1);

printf("Enter second number: ");


scanf("%d", &num2);

result = multiply(num1, num2);

printf("The result of multiplication is: %d\n", result);

return 0;
}

/*__________________________________________End of the Program_______________________________________*/

/*_________________________________________Output of the Program_____________________________________*/

You might also like