#include <stdio.h>
int add(int m, int n) {
if (n == 0)
return m;
return add(m, n - 1) + 1;
}
int main() {
int a, b, sum;
printf("**C Program to add two numbers using recursion**\n");
printf("Enter the first number:\n");
scanf("%d", &a);
printf("Enter the second number:\n");
scanf("%d", &b);
sum = add(a, b);
printf("Sum of two numbers is: %d\n", sum);
return 0;
}
Output
**C Program to add two numbers using recursion**
Enter the first number:
7
Enter the second number:
4
Sum of two numbers is: 11
What did you think?