CPP
Slip 1
a)Write
a C++ program to check maximum and minimum of two integer numbers. (Use Inline
function and Conditional operator)
b)Create
a C++ class MyFile with data members file pointer and filename. Write necessary
member functions to accept and disp lay File . Overload the following
operators:
Operator Example Purpose
+
F3=F l+F2 Concatenate the
contents of file F1 and F2 in F3.
!F3
Chan ges the case of alternate characters of file F3.
Slip 2
a)Writea C++ program to find volume of cylinder, cone and sphere. (Use functionoverloading).
b)Write
a C++ program to create a class Movie with data members M_Name, Release_Year,
Director_Name and Budget. (Use File Handling) Write necessary member functions
to:
1.Accept
details for 'n' Movies from user and store it in a file "M ovie. bet"
.
11.Display
Movie details from a file.
111.Count the
number of objects stored in a file.
Slip 3
a)Writea C++ program to interchange value s of two integer numbers. (Use call byreference)
b)Write
a C++ program to accept ' n' numbers from user through Command Line
Argument.Store all Even and Odd numbers in file "Even.txt" and
"Odd.txt" respectively.
Slip 4
a)Write
a C++ program to accept Worker informati on Worker_Na me, No_of_Hours_worked,
Pay_ Rate and Salary. Write necessary functions to calculate and display the
salary of Worker. (Use default value for Pay_Rate)
b)Write
a C++ program to create a base class Employee (Emp-code, name, salary). Derive
two classes as Fulltime (daily_wages, number_of_days) and Parttime
(number_of_working_hours, hourly_wages). Write a menu driven program to perform
following functions:
1.Accept
the details of ' n ' employees and calculate the salary.
2.Display
the details of ' n' employees.
3.Display
the details of employee having maximum salary for both types of employees.
Slip 5
a)Consider
the following C++ class
class
Point
{
intx,y;
public:
void setpoint(int,
int); void showpoint();
};
//
To set the values ofx and y co-ordinate .
//
To display co-ordinate of a point P in format (x, y).
b)Create
a C++ base class Shape. Derive three different classes Circle, Sphere and
Cylinder from shape class. Write a C++ program to calculate area of Circle,
Sphere and Cylinder. (Use pure virtual function).
Slip 6
a)Write
a C++ program to create two Classes Square and R ec tan gle. Compare
area of both the shapes using friend function. Accept appropriate data
members for both
the classes .
b)Create
a C++ class class Matrix
{
public:
};
int
**p; int r, c;
//member
functions
Write
necessary member functions to:
1.Accept
M atrix elements
11.Display
Matrix elements.
ll
I.Ca lculate transpose of a Matrix .
(Use
constructor and destructor)
Slip 7
a)Write
a C++ program using class with data member char str[50] and function replace
(char ch I , char ch2) every occurrence of ch l in str should be replaced with
ch2 and return number of replacement it makes use default value for char ch2. (Use ch2 as
Default Argument)
b)Create
a C++ class Vector with data memhers size & pointer to intege r. Th e s ize
of the vec tor varies so the memory should be allocated dynamically.
Perfonn
following operations:
1.Accept
a vector
11.Display
a vector in the format (10, 20, 30, )
111.Calculate
union of two vectors.
(use
parameterized constructor & copy constructor)
Slip 8
a)Write
a C++ program to create a class Number, which contain static data member ' cnt'
and member function ' Display() '. Display() should print number of times
display operation is performed irrespective of the object responsible for calling Display().
b)Create
a C++ class Person with data members Person_name, Mobile_number, Age,
City. Write necessary member functions
for the following:
i.Search
the mobile number of given person.
ii.Search
the person name of given mobile number.
iii.Search
all person details of given city.
(Use
function overloading)
Slip 9
a)Consider
the following C++ class
class
Person
{
char
Name [20];
charAdd
r [30];
float
Salary;
floattax_amount;
public: II member functions
};
Calculate
tax amount by checking salary of a person
•For
salary <=20000 tax rate=0
•For
salary >2000011< =40000 tax rate=
5% of salary.
•For
salary >40000 tax rate =10% of salary.
b)Create
a C++ class Time with data members Hours, Minutes and Seconds. Write necessary
member functions for the following: (Use Objects as arguments)
i.To
accept a time.
ii.To
display a time in format hh:mm:ss.
iii.To
find difference between two time and display it in format hh:mm:ss.
Slip 10
a)Write
a C++ program to create a class Account with data members Acc_n umber, Acc_type
and Balance. Write member functions to accept and display ' n' account details.
(Use dynamic memory allocation)
b)Create
a C++ class City with data membersCity_code, City_name, population. Write
necessary member functions for the following:
i.Accep
t details of n cities
ii.Display
details of n cities in ascending order of population.
iii.Display
details ofa particular city.
(Use Array of object and to display city
information use manipulators.)
Slip 11
a)Create
a C++ class MyArray, which contains single dimensional integer array of a give
n size. Write a member function to
display sum of given array elements. ( Use Dynamic Constructor and Destructor)
b)Create
a base class Student with data members Roll_No, Name. Derives two classes from
it, class Theory with data members M l , M2, M3, M4 and class Practical with
data members P l , P2. Class Result(Total_Marks, Perce ntage , Grade) inherit s
both Theory and Practical classes. (Use concept of Virtual Base Class and
protected access specifiers)
Write
a C++ menu driven program to perform the following functions:
i.Accept
Student Information
ii.Display
Student Information
iii.Calcul
ate Total_marks, Percentage and Grade.
Slip 12
a)Write
a C++ program to create a class Date with data members day, month, and year.
Use default. and parameterized constructor to initialize date and display date
in dd-Mon-yyyy format. (Example: Input: 04-01-2021 Output: 04-Jan-2021)
b)Create
a C++ class Weight with data members kilogram, gram. Write a C++ program using
operator overloading to perform following functions:
1.Toaccept
weight.
11.
T o display weight in kilogram and gram format.
111.
Overload += operator to add two weights.
1v.
Overload == operator to check equality
of two we ights.
Slip 13
a)Write
a C++ program to create a class Product
with data members
Product_id, Product_Name, Qty, Price. Write member functio ns to acce
pt and d is pla y Pro du ct info rmation also disp lay number of objects
created for Product class. (Use Static data member and Static member function)
b)Create
a C++ class Cuboid with data members length, breadth, and height. Write
necessary member functions for the following:
1.
voidsetvalues( float,float,floa t) to set values of data members.
11.
voidgetvalues( ) to display values of data members.
111.
floatvolum ( ) to calculate and return the volume of cuboid.
1v.
float surface_ area( ) to calculate and return the surface area of cuboid.
(Use
Inline function)
Slip 14
a)Write
a C++ program to accept radius of a Circle. Calculate and display diameter,
circumference as well as area of a Circle. (Use Inline function)
b)Create
a C++ class MyString with data members a character pointer and str_length. (Use
new and delete operator). Write a C++
program using operator overloading to perform following operation:
1. ! To reverse the case of each alphabet from
a given string.
11.< To compare length of two strings.
111.+ To add
constant ' n' to each alphabet ofa string.
Slip 15
a)Create
a C++ class Fraction with data members Numerator and Denominator. Write a C++
program to calculate and display sum of two fractions. (Use Constructor)
b)Write
a C++ class Seller (S_Name, Product_name, Sales_Quantity, Target_Quantity,
Month, Commission). Eac h s ale sm an deals w ith a separate product and is ass
igned a target for a month. At the end of the month his monthl y sales is
compared with target and commission is calculated as follows:
•If
Sales_Quantity>Target_Quantit y th en commiss ion is 25% of extra sa les
made + I0% of ta rge t.
•If
Sales_Quantit y = Target_Quantity then co mmiss ion is 10% of target.
•Otherwise
commiss ion is zero.
Display
salesman inform ation along with commission obtained. (Use array of objects)
Slip 16
a)Write
a C++ program to create a class Machine with data members Machine_Id,
Machine_Name, Price. Create and initi a lizeallvalues of Machine object by
using parameterized constructor and copy constructor. Display details of
Machine using setw() andsetprecsiion().
b)Create
a C++ class MyMatrix and Write necessary member functions for the following:
i.To
accept a Matrix
ii.To
display a Matrix
iii.Overload
unary ' -' operator to calculate trans pose ofa Matrix .
iv.Overload
unary '++' operator to increment matrix
elements by 1.
Slip 17
a)Create
a C++ class MyMatrix. Write a C++ program to accept and display a Matrix.
Overload binary '- ' operator
to calculate subtraction of two
matrices.
b)Design
two base classes Student (S_id, Name, Class ) and Com petition (C_ id , C_Na me
). Derive a class Stud_Comp(Rank) from it. Write a menu driven program to
perform following functions:
i.Accept
information.
ii.Display
information.
iii.Display
Student Details in the ascending order of Rank of a specified competition.
(Use
array of objects)
Slip 18
a)Create
a C++ class S tud e nt w ith data
members Roll_no, S_Name,
Class, Percentage. Accept
twostudents information and display inform ation of student having
maxim um percentage. (Use
this pointer)
b) Create a C++ class MyArray with data
members
- int *arr
- int size
Write
necessary member functions to accept and display Array elements. Overload the
following operators:
Slip 19
a)Writea C++ program to create a class Distance with data members meter and centimeterto represent distance . Write a function Larger( ) to return the larger of twodistances. (Use this pointer)
b)Create
a C++ base class Media. Derive two different classes from it, class NewsPaper
with data members N_Name, N_Editor, N_Price, No_of_Pages and class Magazine
with data members M_Name, M_Editor, M_Price. Write a C++ program to accept and
display infornrntion of both NewsPaper and Magazine. (Use pure virtual
function)
Slip 20
a)Create
a C++ class Number with integer data member. Write necessary member functions
to overload the operator unary pre and post increment ' ++ ' .
b)Createa C++ class for inventoryof Mobiles with data membersModel,Mobile_Company,
Color, Price and Quantity. Mobile can be sold, if stock is available ,
otherwise purchase will be made. Write necessary member functions for the
following:
i.To
accept mobile details from user.
ii.To
sale a mobile. (Sale contains Mobile details & number of mobiles to be
sold.)
iii.To
Purchase a Mobile. (Purchase contains Mobile details & number of mobiles to
be purchased)
Slip 21
a)Create
a C++ class Employee with data members Emp_id, Emp_Name, Company_Name and
Salary. Write member functions to accept and display Employee information.
Design User defined Manipulator to print
Salary.
(For
Salary set right justification, maximum width to 7 and fill remaining spaces
with '*')
b)Create
a C++ class for a two dimensional points. Write necessary member functions to
accept & display the point object. Overload the following operators:
Operator Example Purpose
+
(Binary) P3=P l+P2 Adds coordinates of point pl and p2.
-
(Unary) -Pl Negates coordinates of point pl.
*(Binary) P2=P l*n Multiply
coordinates of point pl by constant '
n'.
Slip 22
a)Write
a C++ program to define two function templates for calculating the square
and cube of give n numbers with different data types.
b)Write
a C++ program to overload ' display_str' function as follows:
1.
voiddisplay_str(char *) - Display a string in doub le quotes.
11.
voiddisplay_str (int n, char *)- Display first n characters from a given
string.
u1.
voiddisplay_str (int m, intn,char *)- Display substring of a given string from
position m to n.
Slip 23
a)Create
a C++ class MyString with data member character pointer. Write a C++ program to
accept and display a string. Overload '+
' operator to concatenate two strings.
b)Create
a C++ class ComplexNumberwith data members real and imaginary. Write necessary
functions:
i.To
accept Complex Number using constructor.
ii.To
display Complex Number in format [x + iy].
iii.To
add two Complex Numbers by using friend function.
Slip 24
a)Create
a C++ class FixDeposit with data membersFD_No, Cust_Name, FD _Amt, Interest
rate, Maturity amt, Number_of_months. Create and Initialize all values of
FixDeposit object by using parameterized constructor with default value for
interest rate. Calculate maturity amt using interest rate and display all the
details.
b)Create
a C++ class InvoiceBill with data members Order_id, O_Date, Customer_Name,
No_of_Products, Prod_Name[], Quantity[], Pro d_Price[]. A Customer can buy ' n'
products. Accept quantity for each product. Generate and Display the bill using
app ropriateManipulators .(Use
new operator)
Slip 25
a)Write
a C++ program to calculate mean, mode and median of three integer numbers.
(Use
Inline function)
b)Write
a C++ program to read the contents of a "SampleData.txt" file. Create
"Upper.txt" file to store uppercase characters, "Lower.txt"
file to store lowe r case characters, " Dig it.txt " fil e to s tore
digits and " O th er.txt" file to store remaining characters of a
given file.
Slip 26
a)Writea C++ program to find average of 3 integer numhers and average of 3 floatnumhers.(Use function overloading)
b)Create
a C++ class Time with data members hours, minutes, seconds. Write a C++ program
using
operator
overloading to perform the following:
1. != To
check whether two Times are equal or not.
11. >> To
accept the time.
m. << To
display the time.
Slip 27
a)Create
a C++ class College, with data members College_Id, College_Name,
Establishment_year, University _Name. Overload operators>> and <<
to accept and display College information.
b)Create
a base class Travels with data members T_no, Company_Name. Derive a class Route
with data members Route_id, Source, and Destination from Travels class. Also
derive a class Reservation with data
members Number_of_Seats, Travels_Class, Fare, and Travel_Date from Route.
Write
a C++ program to perform following necessary member functions:
i.Accept details of •n' reservations.
ii.Display
details of all reservations.
iii.Display
reservation details of a specified Date.
Slip 28
a)Write
a C++ program to read array of ' n' integers from user and display it in
reverse order.(Use Dynamic memory allocation)
b)Create
a C++ class Employee with data members Emp_Id, Emp_Name, Mobile_No, Salary.
Write necessary member functions for the following:
i.Accept
details of n employees
ii.Display
employee details in descending order of their salary.
iii.Display
details of a particular employee.
(Use
Array of object and Use appropriate manipulators)
Slip 29
a)Write
a C++ program to create a class E_Bill w ith data members Cust_Name, Meter_ID,
No_of_Units and Total_Charges. Write member functions to accept and display
customer information by calculating charges. (Rules to calculate electricity
board charges)
•For
first 100 units : Rs.
1 per unit
•For
next 200 units : Rs. 2 per unit
•Beyond 300 units
: Rs. 5 per unit
All
users are charged a minimum of Rs.150. If the total charge 1s more than
Rs.250.00 then an additional charge of 15% is added.
b)Create
a C++ class VisitingStaff with data members Name, No_of_Subjects,
Name_of_Subjects[],Working_hours, Total_Salary. (Number of subjects varies for
a Staff).Write a parameterized constructor to initialize the data members and
create an array for Name_of_Subjectsdynamically . Display Visiting Staff
details by calculating salary. (Assume remuneration Rs. 300 per working hour)
Slip 30
a)Write
C++ program to create two classes Integer_Array and Float_Array with an array
as a data member. Write necessary member functions to accept and display array
elements of both the classes. Find and display average of both the array. (Use Friend function)
b)Create
a C++ class Marksheet with data members Seat_No, Student_Name, Class,
Subject_Na me[], Int_Marks[], Ext_M arks[], Total[], Grand_Total, Percentage,
Grade. Write member function to accept Student information for 5 subjects.
Calculate Total, Grand_Total, Percentage, Grade and use setw( ), setprecision (
)and setfill ( )to display Marksheet.