Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
478 views

C++ - Assignments New

The document lists 40 C++ programming assignments covering topics such as functions, function overloading, classes, inheritance, templates, exceptions, and more. Some key assignments include: 1. Writing a program to swap variables and overload functions to swap integers, floats, and characters. 2. Defining classes such as Employee and Student with member functions to set/get data and display output. 3. Creating classes to demonstrate concepts like shallow copy, deep copy, private constructors, and dynamic constructors. 4. Overloading operators like unary minus, increment, addition, insertion, and extraction using friend functions. 5. Using inheritance to model exam results with classes like Student, Exam,

Uploaded by

Mohamed Ibrahim
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
478 views

C++ - Assignments New

The document lists 40 C++ programming assignments covering topics such as functions, function overloading, classes, inheritance, templates, exceptions, and more. Some key assignments include: 1. Writing a program to swap variables and overload functions to swap integers, floats, and characters. 2. Defining classes such as Employee and Student with member functions to set/get data and display output. 3. Creating classes to demonstrate concepts like shallow copy, deep copy, private constructors, and dynamic constructors. 4. Overloading operators like unary minus, increment, addition, insertion, and extraction using friend functions. 5. Using inheritance to model exam results with classes like Student, Exam,

Uploaded by

Mohamed Ibrahim
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

C++ Assignments

----------------------------------------------------------------------------------------------------------------------
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

Class Data members Member functions


Student roll , branch read & display
Internal_Exam sub1, sub2 read & display
External_Exam sub1,sub2 read & display
Result total_marks total & display
Note : Use Mutipath Inheritance & Virtual Base class concept.
29.Write a C++ program to sort data items in ascending order using function templates.
30.Write a C++ program to find the minimum of 2 numbers using function template with multiple arguments.
31.Write a C++ to overload a template function.
32.Write a C++ to exchange the values of two variables. Using template variables as a
function arguments in generic way ?
33.Write a C++ program to implement Stack using class templates.
34.Write a C++ program define definition of member function template outside the class and
invoke the function to overload + operator for performing addition of two template based
class objects ?
35.Write a C++ program to define virtual destructors ?
36.Write a C++ program to explain the nested class.
37.Write a C++ program to explain the this pointer.
38.Write a C++ program to accept 10 integers in an array.check all numbers in the array.when
any negative number is found, throw an exception?
39.Write a C++ program to catch multiple exceptions?
40.Write a C++ to throw an exception in derived class?

You might also like