Program 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…
study trigger
-
-
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…
-
ArticleJAVA Programming
Practices Questions on Class and Objects in Java
by Mahesh Vermaby Mahesh VermaJava is one of the most popular programming languages used for developing various applications. One of the key concepts in Java is object-oriented programming, which allows developers to create modular,…
-
A string is a sequence of characters. It is a data type that is used to represent text in a program. Strings are often used for storing and manipulating data…