 ### A program in C++ to calculate the factorial of a given number by using recursion.

To understand the above C++ program to calculate the factorial of a number using recursion, we need to understand what is recursion first. Recursion is a method in C++ which calls itself directly or indirectly until a suitable condition is met. In this method, we repeatedly call the function within the same function, and it…

### A program in C++ to reverse a digit.

In the above C++ program to reverse a digit, arithmetic operation is used to get the desired result. Sample Output: Enter an integer: 4367 Reversed Number is : 7634

### Program in C++ that accepts different numbers n as well as an integer s which is equal to the sum of the n different numbers. Find the number of combinations of n numbers.

The above C++ program that accepts different numbers n as well as an integer s which is equal to the sum of the n different numbers, can be understood with the following example : If n = 3 and s = 6:1 + 2 + 3 = 60 + 1 + 5 = 60 +…

### Program in C++ to display all the leap years between two given years. If there is no leap year in the given period then display an appropriate message.

In the above C++ program to display all the leap years between two given years, we have used conditional statements in a user defined function. And in the main function the user-defined function is called along with the values of the year entered by the user. Sample Output: Enter two years to specify the range:…

### A program in C++ that reads an integer n and prints a twin prime that has the maximum size among twin primes less than or equal to n.

In the above C++ program to prints a twin prime that has the maximum size among twin primes less than or equal to the given number, we need to understand that A twin prime is a prime number that is either 2 less or 2 more than another prime number—for example, either member of the…

### C++ program to swap two variables without using a third variable.

In the above C++ program to swap two numbers without using a third variable, we have used arithmetic logic to get the desired result. Sample Output: Input first number : 45 Input second number : 76 After swapping the first number is : 76 After swapping the second number is : 45