Program 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);…
Programs
-
C++ ProgramsProgramsRecursive Function
-
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…
-
Java ProgramsPrograms
Practice questions on Java Classes and Objects – Find types of food on the basis of Sticker
by Mahesh Vermaby Mahesh VermaDefine a class SUPPLY in Java with the following descriptions : Members are : Code of int type, FoodName of type String, Sticker of type String, FoodType of type String.…
-
Java ProgramsPrograms
Practice questions on Java Classes and Objects – Find car rent using car type.
by Mahesh Vermaby Mahesh VermaDefine a class CARRENTAL with the following details : Class Members are : CarId of int type, CarType of string type and Rent of float type. Define GetCar() method which…