C Program to Add Two Numbers Using Recursion
Recursion is a programming technique that allows the programmer to express operations in terms of themselves. In C, this takes the form of a function that calls itself.
- //C program to add two numbers using recursion
-
- #include <stdio.h>
- #include <stdlib.h>
- int add(int,int);
- int main()
- {
- int a,b,r;
- printf("enter two numbers: ");
- scanf("%d %d",&a,&b); //taking input
- result=add(a,b); //calling the recursive function
- printf("Sum of two numbers are: %d\n",result); //output
- getch();
- return 0;
- }
- int add(int a,int b) //recursive function
- {
- if(y==0)
- return a;
- else
- return(1+add(a,b-1));
- }
Output

Solution not working or have any suggestions? Please send an email to [email protected]
Download Android App