Program to find the GCD of two numbers using recursion in C++ Solution : #include <iostream> using namespace std; int GCD(int a,int b) { while(a!=b) { if(a>b) return GCD(a-b,b); else…
Mahesh Verma
Mahesh Verma
I have been working for 10 years in software developing field. I have designed and developed applications using C#, SQL Server, Web API, AngularJS, Angular, React, Python etc. I love to do work with Python, Machine Learning and to learn all the new technologies also with the expertise to grasp new concepts quickly and utilize the same in a productive manner.
-
-
C++ ProgramsProgramsRecursive Function
Program to find Factorial of a number using recursion
by Mahesh Vermaby Mahesh VermaProgram to find Factorial of a number using recursion in C++ Solution #include <iostream> using namespace std; int factorial(int n) { if(n==1) return 1; else return n*factorial(n-1); } int main()…
-
C++ ProgramsProgramsRecursive Function
Write a program to calculate reverse of a number using recursion.
by Mahesh Vermaby Mahesh VermaProgram to calculate reverse of a number in C++. Solution: #include <iostream> using namespace std; int rev(int n) { static int r=0; if(n==0) return r; else { r=(r*10)+n%10; return rev(n/10);…
-
C++ ProgramsProgramsRecursive Function
Program to find the sum of digits of a number using recursion.
by Mahesh Vermaby Mahesh VermaProgram to find the sum of digits of a number using recursion in C++. Solution #include <iostream> using namespace std; int sumdigit(int n) { if (n == 0) return 0;…
-
C++ ProgramsProgramsRecursive Function
Program to count the digits of a given number using recursion
by Mahesh Vermaby Mahesh VermaProgram to count the digits of a given number using recursion in C++. Solution : #include <iostream> using namespace std; int CountD(int n) { static int count=0; if (n >…
-
C++ ProgramsProgramsRecursive Function
Program to calculate the sum of numbers from 1 to n using recursion
by Mahesh Vermaby Mahesh VermaProgram to calculate the sum of numbers from 1 to n using recursion in C++. Solution #include <iostream> using namespace std; int sum(int n) { if (n != 0) return…
-
C++ ProgramsProgramsRecursive Function
Print the first 50 natural numbers using recursion.
by Mahesh Vermaby Mahesh VermaProgram to print the first 50 natural numbers using recursion in C++. Solution : #include <iostream> using namespace std; void natural(int n) { if(n<=50) { cout<<n<<“\t”; natural(n+1); //function call itself…
-
C++ ProgramsProgramsRecursive Function
Recursive Function with Practice Problems
by Mahesh Vermaby Mahesh VermaRecursive Function : A recursive function is a function that calls itself during its execution, either directly or indirectly. It is a powerful and elegant technique that allows solving complex…
-
Java ProgramsPrograms
Practice questions on Java Classes and Objects – Create a Class Bank
by Mahesh Vermaby Mahesh VermaCreate a class Bank with the following Menu : Display all account details Search by account number Deposit the amount Withdraw the amount Exit Solution import java.util.Scanner; class BankOperations {…
-
Java ProgramsPrograms
Practice questions on Java Classes and Objects – Find resort’s charges on the basis of days
by Mahesh Vermaby Mahesh VermaDefine a class Resort with the following description: Members are : RNo to store Room Number, Name store customer name, Charges to store per day charges, Days to store number…