Questions
Questions
2. Design a class “Distance” with kilometers, meters, and centimeters as data items. Provide
parameterized and copy constructor and overload ‘*’ operators.
1. Design a class “Distance” with kilometers, meters, and centimeters as data items. Provide
parameterized and copy constructor and overload ‘-’ binary operators.
2. Write a program to reverse a given number using inline function.
1. Design a class “Distance” with kilometers, meters, and centimeters as data items. Provide
parameterized and copy constructor and overload ‘+’ operators.
2. Write a C++ program to print stars Sequence using inline function.
*
**
***
****
*****
1. Design a class “Time” with Hours, minutes and seconds as data members. Provide parameterized and
copy constructor and overload ‘+’, operators. .(Using Operator overloading)
2. Write a C++ program to concatenate 2 strings by showing use of dynamic constructor.
1. Define 2 classes which accepts 5 integers each. Using friend function sort and print these 10 integers.
2. Write a C++ program to print first ten terms of Fibonacci series.
1. Define a class student and show the use of static variable to auto generate Roll No of a student along
with their primary information.
2. Write an inline function to obtain the largest of three numbers.
1. Write a C++ program to find area and perimeter of rectangle using function template.
2. Write a function that takes two Distance values as arguments and returns the larger . Include a main()
program that accepts two Distance values from the user, compare them, and displays the larger.( use
object as function argument, Write the function inside the class)
Member Functions :- To assign initial values , To deposit an amount , To withdraw an amount after checking
the balance , To display name and balance.
2) Write a program in C++ to demonstrate the use of static data member & static member function.
1. Create two classes DM and DB, which store the value of distances. DM stores distances in meters
and centimeters and DB in feet and inches. Write a program that can read values for the class objects
and add one object of DM with another object of DB. Use a friend function to carry out the addition
operation. The object that stores the results may be a DM object or DB object depending on the units
in which the results are required. (1 foot = 0.3048 meters, 1 inches = 2.54 centimeters)
2. Write a program in C++ to find all Armstrong nos. in the given range.
1. Write a program to calculate average percentage of 5 subjects for 5 students along with their name
and roll no. using array of object.
2. Design a class string that will store array of characters provide suitable constructors and over loaded
operator + to concatenate two strings. (Using Operator overloading)
1. Write a C++ program for Exception Handling Divide by zero Using C++ Programming
2. Create a class Master that derives information from both Account(pay) and Admin(experience)
classes which in turn derive information from the class Person(name, code). Define all the four
classes and write a program to create, update and display the information contained in Master
objects.
1. Create a class distance which accept the distances in feet & inches from the user & display the sum
of two distances in feet & inch. [ use object as function argument, Write the function inside the class
] Modify above program to return the distance as an object of same class.
2. Write a program to copy the contents of one file to another.
1. Create two classes manager & scientist having data members salary1 & salary 2 respectively to store
salary. Write a function which finds the maximum salary between two salaries. [Use friend function]
2. Write a C++ program to swap a data using function template.
1. Create a class student (roll_no, name) Derive two classes Science (maths, phy, comp) and
Commerce(acc, stats). Accept details of 10 students, they could be Science or Commerce students.
Display the details of all the students in same order of acceptance ( Use Virtual Function)
2. Write a program to maintain a elementary database of employees using files.
1) Define base class Student with Roll_No, Name , Marks1 , Marks2 , Marks3 as data members. Define
Sports class with SportName , ParticipationLevel , Achievement as data members and also find
sports grade . Inherit Student Class in Sports Class to find final grade of five students. (District/Gold
- 3 District/Silver – 2 District/Bronze – 1
State/Gold - 6 State /Silver – 5 State /Bronze – 4
National/Gold - 9 National/Silver – 8 National/Bronze – 7)
2) Write a C++ program to solve Quadratic Equation using constructor.
1. Write a C++ program which reads a text file and prints every alternative character from the file.
2. Write a class ‘Point’ with x and y coordinates as data members. Derive two classes ‘Line’ and
Circle’ from ‘Point’ with appropriate data members. Derive a class ‘Triangle’ from class ‘Line’.
Implement read () and draw () member functions for all the above classes.
1. Write base class that ask the user to enter a complex number and derived class adds the complex
number of its own with the base. Finally make third class that is friend of derived and calculate
the difference of base complex number and its own complex number.
2. Write a C++ program to make arithmetic calculator using inline function.
1. Write a C++ program to maintain the records of person with details (Name and Age) and find the
eldest among them. The program must use this pointer to return the result.
2. Create a class Length containing data members mtrs and cms. Create a class Distance containing
data members kms and mtrs. Write a friend function compare( ) which takes two parameters
length object and distance object and returns the difference in cms.
1. Write a C++ program implementing stack and it’s operations using template class.
2. Write a program to design a class having static member function named showcount() which has
the property of displaying the number of objects created of the class.
1. Write a program to derive a class rectangle from base class shape using single inheritance.
2. Declare class ‘STACK’ and handle the run time anomalies like Overflow – when the stack is
full & Underflow – when the stack is empty. Display error numbers and error message when error is
thrown.(Use Exception Handling)
1. Write a C++ program for Exception Handling Divide by zero Using C++ Programming.
2. Design and Implement Class ‘String’ with a default, parameterized and copy Constructors. Provide
member functions to accept and display string and friend function to concatenate and compare two
strings without using operator overloading.
1. Write three derived classes inheriting functionality of base class person (should have a member
function that ask to enter name and age) and with added unique features of student, and employee,
and functionality to assign, change and delete records of student and employee. And make one
member function for printing address of the objects of classes (base and derived) using this pointer.
1) Consider a book shop which sales books and video tapes. Define a class Media which store title and
price of a publication. Create two derive classes book and tape where book class is used to store no
of pages of book and tape class is used to store playing time of a tape. Use display function in all the
classes and show the use of virtual function.
1. Write a program to declare a class ‘Account’ having data members as account_no and balance.
Accept and display data for objects using pointer to the array of objects.
2. Write a C++ program implementing linked list & some required operations on it using class template.
1. Write a program of multiple inheritance for a company that publishes and markets books. Derive a
pamphlet , book and tape from publication And tape & book from sales. And notice from pamphlet.
Display a book information.
1. Write a program to find mean value of given number using friend function.
2. Create a class FLOAT that contains one float data member. Overload all the four arithmetic operators
so that they operate on the objects of FLOAT.
1. Write a Program to Find the Number of Vowels, Consonants, Digits and White space in a String
using file
2. Write a C++ program to print first 10 terms of Fibonacci series using constructor.
1) Create a class ‘Account’ that stores customer name, account number and type of account. From this
derive the classes cur_acct and sav_acct to make them more specific to their requirements. Include
necessary member functions in order to achieve the following tasks:
a) Accept deposit from a customer and update the balance. b) Display the balance.
c) Compute and deposit interest. d) Permit withdrawal and update the balance.
1. Write a C++ program to show the use of static data member and static member function.
2. Write a program by using friend class swap the private data.
1. Write a C++ program to maintain book inventory of books that are being sold at the shop. The list
includes details such as book_id, author, title, price, and stock position. Whenever a customer wants
a book, system should search for the book and displays whether it is available or not. If the book with
requested copies are available, then total cost for the requested quantities should display otherwise
the message “Requested copies not available” is displayed. The system will also maintain the stock.
1. Write a program to design a class having static member function named showcount() which has the
property of displaying the number of objects created of the class.
2. Create two classes manager & scientist having data members salary1 & salary 2 respectively to store
salary. Write a function which finds the maximum salary between two salaries. [Use friend function]
1. Write a program to implement I/O operations on characters. I/O operations includes inputting a
string, Calculating length of the string, Storing the string in a file, fetching the stored characters
from it, etc.
2. Write a C++ program for Exception Handling Divide by zero Using C++ Programming.
1. Create a class student (roll_no, name) Derive two classes Science (maths, phy, comp) and
Commerce(acc, stats). Accept details of 10 students, they could be Science or Commerce
students. Display the details of all the students in same order of acceptance ( Use Virtual
Function)
2. Write a C++ program to solve Quadratic Equation using constructor.
1. A class of n students take an annual examination in m subjects. A program to read the marks
obtained by each student in various subjects and to compute and print the total marks obtained by
each of them.
2. Write a C++ program to print personal information of employee and managers.
1. Create a class distance which accept the distances in feet & inches from the user & display the sum
of two distances in feet & inch. [ use object as function argument, Write the function inside the class
] Modify above program to return the distance as an object of same class.
2. Design a class string that will store array of characters provide suitable constructors and over loaded
operator + to concatenate two strings. (Using Operator overloading)
1. Write a program of multiple inheritance for a company that publishes and markets books. Derive a
pamphlet , book and tape from publication And tape & book from sales. And notice from pamphlet.
Display a book information.
1. Define two classes TheoryClass & PracticalClass. Accept marks for 5 theory subjects in
TheoryClass and marks of 2 practical subjects in PracticalClass. Write a program to find percentage
of 5 students using friend function. (Show the use of constructor)
2. Write a C++ program to sort an array in ascending order using function template.
1. Create a base class called shape. Use this class to store double type values that could be used to
compute the area of figures. Derive two specific classes called triangle and rectangle from the base
shape. Add to the base class, a member function get_data() to initialize base class data members and
another member function disp_area() to compute and display area of figures. Make disp_area() as a
virtual function and redefine it in the derived classes to suit their requirements.
2. Write a C++ program to find out average of two numbers by using function.
1. Create a class MAT of size m*n. Define all possible matrix operations for MAT type objects.
2. Write a program for reading and writing data to and from the file.
1. Design a class “Distance” with kilometers, meters, and centimeters as data items. Provide
parameterized and copy constructor and overload ‘+’ operators.
2. Write a C++ program to print stars Sequence using inline function.
*
**
***
****
*****