Program : Find the kth largest element in an array in C++. Solution: #include <iostream> using namespace std; int findKthLargest(int array[], int size, int k) { int maxIndex, i, j;…
Programs
-
-
Program : Find the median of an array. Explanation : The median of an array is the middle element when the array is sorted in ascending order. In other words,…
-
Array ProgramsC++ ProgramsPrograms
Find the frequency of each element in an array.
by Mahesh Vermaby Mahesh VermaProgram : Find the frequency of each element in an array. Solution : #include <iostream> using namespace std; void findFrequency(int array[], int size) { const int MAX_SIZE = 100; int…
-
Program : Check if an array is a palindrome in C++. Explanation: To check if an array is a palindrome or not, we need to understand what a palindrome is.…
-
Java ProgramsPrograms
PRACTICE QUESTIONS ON ABSTRACT CLASS – CLASS SHAPE
by Mahesh Vermaby Mahesh VermaCreate an abstract class “Shape” with abstract methods “getArea()” and “getPerimeter()”. Implement two subclasses “Rectangle” and “Circle” which extend “Shape” and implement the abstract methods. Create a “Square” class which…
-
Java ProgramsPrograms
PRACTICE QUESTIONS ON ABSTRACT CLASS – CLASS BANK
by Mahesh Vermaby Mahesh VermaCreate an abstract class “BankAccount” with abstract methods “deposit()” and “withdraw()”. Implement two subclasses “SavingsAccount” and “CheckingAccount” which extend “BankAccount” and implement the abstract methods. Create a “Customer” class which…
-
Java ProgramsPrograms
PRACTICE QUESTIONS ON ABSTRACT CLASS – CLASS EMPLOYEE
by Mahesh Vermaby Mahesh VermaCreate an abstract class “Employee” with abstract methods “calculateSalary()” and “displayEmployeeDetails()”. Implement two subclasses “Manager” and “Worker” which extend “Employee” and implement the abstract methods. Create a “SalesPerson” class which…
-
Java ProgramsPrograms
PRACTICE QUESTIONS ON ABSTRACT CLASS – CLASS BANK CALCULATE INTEREST
by Mahesh Vermaby Mahesh VermaCreate an abstract class “Account” with abstract method “calculateInterest()”. Implement two subclasses “SavingsAccount” and “CurrentAccount” which extend “Account” and implement the “calculateInterest()” method. Create objects of both classes and test…
-
Java ProgramsPrograms
PRACTICE QUESTIONS ON ABSTRACT CLASS – CLASS MARKSHEET
by Mahesh Vermaby Mahesh VermaAn abstract class called “Marks” is needed to calculate the percentage of marks earned by students A in three subjects (with each subject out of 100) and student B in…
-
C++ ProgramsProgramsRecursive Function
Program to print all even digit from a number using recursion
by Mahesh Vermaby Mahesh VermaProgram to print all even digit from a number using recursion in C++. Solution #include <iostream> using namespace std; void calculate(int n){ if(n == 0) return; calculate(n / 10); if((n%10)%2==0)…