C++ - Assignments New
C++ - Assignments New
----------------------------------------------------------------------------------------------------------------------
1.Write a C++ program to swap two variables using function. (Don't use Pointers).
2.Write a C++ program to swap two integers, floats and characters using function Overloading
3.Write a C++ program to find the area of rectangle, triangle, and sphere using function Overloading.
4.Write a C++ program to define a function with default Arguments. Whenever the function needs default values of
arguments, it will prompt the user to enter a default value. Display the values?
5.Write a C++ programe with the Employee class that creates five employees; sets their Age,
Year of Service, and Salary; provide a method of Employee that reports how many thousands of rupees the
employee earns, rounded to the nearest Rs.80,000/-.
6.Write C++ program to calculate simple interest. Define the class called interest and hide the data elements of the
class using private keyboard. Define the setdata member function to read the data through keyboard and define the
print member function outside the class.
Formulae : interest = (P * N * R) / 100;
Total_amount = interest + P;
here, P -> Principle amount
N -> Period (No.of years)
R -> rate of interest
7.Write a C++ program to define a class called Student with data members as roll, name and marks. Define the
appropriate member functions, 1)setdata 2)display for reading and displaying the data and also define a member
function called sort to sort 5 students records according to roll, name & marks.
8.Write a C++ program to create a class complex with real and imaginary parts perform addition and subtraction of two
complex objects.
9.Write a C++ Program to define 3 classes. Read & Display the data for 3 classes using friend function.
10.Write a C++ Program to exchange values of two variables b/w two classes using friend function.
11.Write a C++ program to find total salary of husband and wife using a friend function. Create
a class to hold the information of husband and another for the wife information.
12. Write a C++ Program to declare 3 classes. Declare private integers array as data members in each class. Perform
addition of two data member arrays into array of third class using friend function.
13.Write a C++ program to demonstrate Shallow Copy.
14.Write a C++ program to demonstrate Deep Copy.
15.Write a C++ program to impliment Private Constructor.
16.Write a C++ program to demonstrate Dynamic Constructor.
17.Write a C++ program to sort the given five names from the keyboard and print it in the sorted order. (Use C++'s
DMA).
18.Write a C++ program to demonstrate Singleton Class.
19.Write a C++ program to Overload unary ' - ' operator.
20. Write a C++ program to Overload Post increment(++) and Pre increment(++) operators
using freind function.
21.Write a C++ program to Overload binary ' + ' operator for the given expression.
OBJ2 = 100+OBJ1 (Hint: Use Friend Function)
22.Write a C++ program to Overload insertion (<<) and extraction (>>) operators using friend functions.
23.Write a C++ program to Overload new and delete operators.
24. Write a C++ program to Overload [ ] operator.
25.Write a C++ program to Overload ( ) operator.
26. Write a C++ program to Overload -> operator.
27.Write a C++ program to demonstrate Hybrid Inheritence.
Consider a example of declaring the examination result. Design three classes: student, exam and result. The
student class has data members such as those representing roll number,name etc. Create the class exam by inheriting
the student class. The exam class adds data members representing the marks scored in six subjects. Derive the result
from the exam class and it has its own data members such as total_marks. Write an interactive program to model this
relationship. What type of inheritance this model belongs to ?
28.Write a C++ program to design a base class called student, Internal_Exam, External_Exam, Result. These classes
should have the following datamembers and member functions