In this tutorial, we will discuss a concept of the Use of C++ program to find sum of two numbers using recursion
In this article, we are going to learn how to find the addition of two numbers using recursion in the C++ programming language
Program
This program allows entering two digits from the user to find the addition of two numbers using the recursive function in C++ programming language
#include <iostream> #include <conio.h> using namespace std; int add(int,int); int main() { int x,y,result; //variable declaration cout<<"enter two integers: "; cin>>x>>y; result=add(x,y); cout<<"Sum of two numbers are:"<<result; getch(); return 0; } int add(int x, int y) { if(y==0) return x; else return(1+add(x,y-1)); }
When the above code is executed, it produces the following results
Enter two integers: 12 34 Sum of two numbers are: 46
Method
Similar post
C++ code to the sum of two numbers
C++ code to sum of two numbers using the function
C++ program to sum of numbers in an array
Suggested for you
C# inverted full pyramid star pattern In this article, we will discuss the concept of…
C# Full Pyramid star pattern program In this article, we will discuss the concept of…
Program to count vowels, consonants, words, characters and space in Java In this article, we…
How to print multiplication table using Array in C++ language In this post, we will…
C Program to multiplication table using Array In this tutorial , we will discuss about…
Java program to check odd or even using recursion In this tutorial, we discuss a…