Program 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…
Programs
-
C++ ProgramsProgramsRecursive Function
-
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…
-
Java ProgramsPrograms
Practice questions on Java Classes and Objects – Find result on the basis of score
by Mahesh Vermaby Mahesh VermaDefine a class Candidate with the following description Members are : RNo of int type, Name of type String, Score of type float, Remarks of type String. Member functions :…
-
Java ProgramsPrograms
Practice questions on Java Classes and Objects – Find price on the basis of Fabric
by Mahesh Vermaby Mahesh VermaDefine a class Garments with the following description : Members are : GCode of type String, GType of type String, GSize of type integer, GFabric of type string, GPrice of…
-
Java ProgramsPrograms
Practice questions on Java Classes and Objects – Find fare on the basis of distance
by Mahesh Vermaby Mahesh VermaDefine a class Tour with the following description: Members are : TCode of type String, NoofAdults of type integer, NoofKids of type integer, Kilometers of type integer, TotalFare of type…