CTUC103 - Practical Assignment-5
CTUC103 - Practical Assignment-5
1
5 Write a Program for Function Overloading (Addition of Different Types of
Numbers):
Overload functions to perform:
Addition of two integer numbers.
Addition of three integer numbers.
Addition of two float numbers.
Addition of three float numbers.
6 Write a program to input one number in a base class and one number in a
derived class. Perform basic arithmetic operations by using a member function
in a derived class.
7 Construct a class Month with data members as Month_No. Write down
overloaded operator++ for the increment the month number by one. Write a
member function read() and display() to read a number of month and print a
number of next month.
Input: Input:
Enter month number: 8 Enter month number: 12
Output: Output:
Next Month number is: 9 Next Month number is: 1
8 Construct a class Month with data members as Month_No. Write down
overloaded operator- - for the decrement the month number by one. Write a
member function read() and display() to read a number of month and print a
number of next month.
Input: Input:
Enter month number: 8 Enter month number: 1
Output: Output:
Previous Month number is: 7 Previous Month number is: 12
9 Construct a class Week with data members as Week_Day_Number. Write down
overloaded operator ++ for the increment the Week Day number by one. Write
a member function getdata() and showdata() to input a number of Week Day
and print Week Day number of previous day.
Input: Input:
Enter Day number: 5 Enter Day number: 7
Output: Output:
Next Day number is: 6 Next Day number is: 1
10 Construct a class Arithmetic with data member as Number. Write down all the
arithmetic operator overloaded i.e +, -, *, / for basic arithmetic operations. Write
a member function to read() and display() the result of operations performed
on user defined data types.
11 Write a Program to demonstrate unary operator overloading in C++.
2
12 Write a Program to demonstrate unary operator overloading using a friend
function.
13 Write a program to define a class Time with hours and minutes as data
members. Implement a getData() method to accept values for two objects and
use binary operator overloading (+ operator) to add two Time objects. Display
the result in a properly formatted manner.
14 Write a program to define a class Time with hours and minutes as data
members. Implement a getData() method to accept values for two objects and
use a friend function to overload the + operator for adding two time objects.
Display the result in a properly formatted manner.