A446685478 - 21976 - 2 - 2018 - Practice Questions1

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

Practice Questions

Class and object, function outside class

1. Suppose that a new outlet of Lovely Autos has opened its new branch in a city. It allows the
manager to keep the records of all cars. For this, they need the detail of the car like, manufacturer,
model name, engine number, chassis number, year of manufacture and color. Create a class with
member functions for entering the required details of the car and displaying the output in a proper
format.

Inline function

2. Suppose that Google has opened his office in Chandigarh recently. Now there is the requirement
for the new employees in a company. The manager to keep the records of all Employees. For this,
they need the detail of the employee like employee name, experience of the employee, age, status
of the employee (married or unmarried).Create a class with member functions for entering the
required details of the employee and inline function for displaying the output in a proper format
and check whether the employee is eligible or not.

Static data members and member functions

3. Suppose that a student wants take the admission in LPU, he needs to enter his information to
take admission. University provides admission for 2017 or 2018.You need to design a program to
generate a unique registration number for each new admission, and it should be incremented by
1. You can use static member function to check the status of registration number.

Structure

4. A university has maintained the records of 10 students like name, rollno, address-city, pincode,
district, regno, and marks in a structure. WAP to search the student with name “Rakesh” in
structure and display his location in the record.

Function with default arguments

5. Suppose you want to invest your money in bank fixed deposit. You want to invest for minimum 3
years and rate of interest given by bank in 8.5 %. Now you want to check what will be the final
amount that you will be getting at the end. If there are two ways of computing interest as simple
interest and compound interest. So find the final amount that you will be getting if it computed as
simple interest and what will be amount that you will be getting if it computed as compound
interest. As the rate of interest is fixed so put this as a default arguments to functions.

Formula : Simple Interest : Amount*rate*time/100


Compund Interest: Amount*(1+rate)time
Function Overloading
6. Suppose that in company ABC Ltd a Graphic designer has drawn shapes like circle, square and
rectangle on a sheet to draw a clown .After drawing he wants to calculate area of circle, square
and rectangle using the dimensions taken by him for drawing shapes. Use concept of function
overloading to calculate the area of the mentioned shapes drawn by the designer.

7. Suppose in Lovely Professional University a student came to take admission and went to
admission counter. The admission in-charge wants to enter student detail information like
name , father’s name, mother name, age and fee to be paid. So use concept of function
overloading to create a function to enter student name, The same function should be used to
enter father’s name and mother name. The same function should be used to enter age and fee
to be paid by student for a particular course and display the information .Check eligibility of the
student by checking age .

Friend function and class

8. One person X has the information of temperature and humidity value of the day. He shares this
information with his family member only. Now, another person Y wants these values but he is
not a family member. Now the question is, how does the person Y takes the information from
person X?

Call by value

9. Person X wants the help of person Y to calculate his percentage. Person Y can perform some
action, which is needed by person X. Then person X has to pass some information (marks of three
subjects) to person Y, so that person Y can perform the action using this information and give the
result. Now the question is, how does the person X pass the information?

UNIT 2
Void pointer

10. The manager of security firm asks his employee to store the data about product number, cost,
supplier_ID and status (a or i). But due to restrictions he cannot use the variables name, he has
to use a single pointer to each variable. WAP to store the above details with using single pointer.
A is active and I is for inactive

Pointer to member and object


11. Create a class of movie data member like title, year, award, hero, heroine, type of movie, and
language. And declare an object and pointer to the class movie, and invoke the data members
using pointer and to search the movie with name “PK” and display remaining details of “PK”.

This Pointer
12. Calculates the area of rectangle by accessing the data member’s l and b using this pointer.

UNIT 3

13. Suppose a bank want to store the detail of a customer like customer_name, account_number,
DOB and balance in the account. Create a class customer with 4 data members and 1 member
function to display the detail on the screen. Delete the object latter on using destructor. Declare
one parameterized constructor to initialize the detail of bank customer.

14. Suppose you are the class incharge of your class and the school has given you responsibility of
sending results to the parents of the students. New students are enrolled in your class. For this,
you will be requiring address details of the students like student name, fathers name, House no,
Street, colony name, village, city, district, country and zip-code of new student. Using
constructors and appropriate member functions, create a class for entering the required address
details of the student. Use the destructors to destruct the memory and show the detail of the
student is closed.

15. Suppose that examination is going on in a school. There are 2 subjects science and maths that are
included as part of exams. There are few students in every section and few students have same
marks. So we need to copy marks of one of the student to another student. For that create a class
named marks and make use of copy constructor to copy the marks from 1 student to another.

You might also like