Assignment-C++-Final-student
Assignment-C++-Final-student
Q1:Simple problem
Q2:Using Class and Object
Q3:Using Constructor and Destructor
Q4:Using Friend function and Friend Class
Q4 friend function distance() that calculates and returns the distance between two Point
objects using the distance formula.
Q4 and price. Define a friend function applyDiscount() that calculates and displays the
price after a discount is applied
Q4 width. Define a friend function findMaxArea() that compares two Rectangle objects
and returns the one with the larger area.
Q4 imaginary. Define a friend function addComplex() to add two complex numbers and
another friend function subtractComplex() to subtract two complex numbers.
Q3 have been created using a constructor, and prints a message when an object is
destroyed using a destructor.
Write a C++ program to define a class Book with private attributes title and price.
Q4 Define a friend function displayBookDetails() that takes two Book objects and
displays their details.
Q1 Write a C++ program to calculate the factorial of a given number using a loop.
Write a C++ program to create a class Greeting with a method sayHello() that displays
Q2
a greeting message like "Hello, [name]!" where the name is provided as input.
Write a C++ program to create a class Product with attributes name and price. Use a
Q3 constructor to initialize name with a default value and price with a default value, but
6 BALAARUNA M
allow the user to change the price during object creation.
Write a C++ program to define two classes Car and Engine. The Car class has private
attributes carModel and carColor, and the Engine class has private attributes
Q4
engineType and horsePower. Define the Engine class as a friend of the Car class to
access and display the car's details
Write a C++ program to check if a number is a palindrome or not (a number that reads
Q1
7 BHAGAVATHI A the same forward and backward).
Q2 Write a C++ program to create a class MathOperations with a method power() that
calculates the power of a number raised to another number.
Write a C++ program to create a class Greeting that displays a welcome message
Q3 when an object of the class is created (using the constructor) and another message
when the object is destroyed (using the destructor).
Write a C++ program to create a class Box with private attributes length, width, and
Q3 a constructor to initialize these values and a destructor to print a message when the
object is destroyed. Also, include a method to calculate the area of the rectangle.
Write a C++ program to create two classes ClassA and ClassB, where both classes
Q4 have private attributes. Define a third class ClassC as a friend of both ClassA and
ClassB to access and display the private attributes of both classes.
Q1 Write a C++ program to find the sum of the digits of a given number.
Write a C++ program to define a class Factorial with a method computeFactorial()
Q2
that calculates the factorial of a given number.
Write a C++ program that dynamically allocates memory for an object of a class
11 DEEPAN R Write a C++ program to create a class Employee with attributes name and salary. Use
Q3
a constructor to initialize an array of Employee objects and display their details.
Write a C++ program to define two classes: Library with private attributes bookTitle
Q4 and author, and Member with a private attribute memberName. Define a friend class
Transaction that can access the private data of both Library and Member to record and
display a book transaction.
Q4 marks. Define another class Result as a friend of the Student class to access and
display the student's marks.
Q4 and seconds. Define a friend function addTime() that adds two Time objects and
returns the sum of both times.
Write a C++ program to convert temperature from Celsius to Fahrenheit and vice
14 EZHILARASAN T Q1
versa.
Write a C++ program to create a class Number with two integer attributes. Create a
Q2
method findGreater() to find and display the greater of the two numbers.
Write a C++ program to define a class Account with a private attribute balance.
Q4 and imaginary. Define a friend function addComplex() to add two complex numbers
and return the result.
Q1 Write a C++ program to print all prime numbers between two numbers.
Write a C++ program to create two objects of the class Person, each with different
Q2
values for name and age. Display the details of both objects.
Write a C++ program to create a class Student with attributes name, rollNumber, and
15 GNANAVEL V Q3 marks. Implement constructor overloading to initialize the object with different sets of
parameters.
Write a C++ program to define a class Point with private attributes x and y. Define a
Q4 friend function comparePoints() to compare two Point objects and return whether they
are equal or not based on their coordinates.
Q1 Write a C++ program to find the greatest common divisor of two numbers.
Write a C++ program to define a class Account with an attribute balance. Implement a
16 HARI HARAN V
Q2 constructor to initialize the balance and a destructor to display a message when the
object is destroyed.
Write a C++ program to define a class Car with attributes make, model, and year. Use
Q3
a parameterized constructor to initialize these attributes when the object is created.
Write a C++ program to create a class Number with private attribute value. Define a
Q4
friend function swapValues() to swap the values of two Number objects.
Q1 Write a C++ program to find the least common multiple of two numbers.
Write a C++ program to create a class Student with private attributes name and age.
Q2
Implement getter and setter functions to access and modify these attributes.
Write a C++ program to define a class Rectangle with attributes length and width. Use
Q3 a default constructor to initialize these attributes to default values (e.g., 0). Display the
17 HARIPRIYA G
dimensions of the rectangle.
Write a C++ program that defines two classes: Person and Address. The Address class
has private attributes street, city, and zipCode, and the Person class has private
Q4
attributes name and age. Define a friend function displayDetails() that can access and
display both Person and Address details.
Q4 height. Write a friend function setDimensions() to modify the private attributes of the
Box object.
Q1 Write a C++ program to find the transpose of a matrix.
Write a C++ program to define a class Rectangle with attributes length and width.
Q2 Create member functions to set the values of these attributes and calculate the area
and perimeter.
Write a C++ program that defines a class Book with attributes title, author, and price.
19 HARSHINI A
Q3 Use a constructor to initialize these attributes and a destructor to display a message
when the object is destroyed.
Write a C++ program to create a class Account with private attributes accountNumber
Q4 and balance. Write a friend function displayBalance() to access and display the
account balance.
Q1 Write a C++ program to count the number of vowels and consonants in a string.
Write a C++ program to define a class Circle with a private attribute radius. Create
Q2
public methods to set and get the value of radius and calculate the area of the circle.
Write a C++ program to create a class ComplexNumber with attributes real and
20 HARSHINI R Q3 imaginary. Use a constructor to initialize these values and a destructor to print a
message when the object is destroyed
Write a C++ program to define a class Rectangle with private attributes length and
Q4 width. Define a friend function calculateArea() that calculates and displays the area of
the rectangle.
Q1 Write a C++ program to reverse a string without using any built-in functions.
21 HASNA BEHUM H Write a C++ program to create a class Calculator with a member function add() that
Q2
takes two integers as input and returns their sum.
Write a C++ program that defines a class Employee with attributes employeeName
Q4 friend function distance() that calculates and returns the distance between two Point
objects using the distance formula.
Q4 and price. Define a friend function applyDiscount() that calculates and displays the
price after a discount is applied.
Q1 Write a C++ program to find the length of a string without using built-in functions.
Write a C++ program to create a class BankAccount with methods to calculate and
Q4 width. Define a friend function findMaxArea() that compares two Rectangle objects
and returns the one with the larger area.
Write a C++ program to count how many times a particular character appears in a
Q1
string.
Write a C++ program to create a class Greeting with a method sayHello() that displays
Q2
a greeting message like "Hello, [name]!" where the name is provided as input.
Write a C++ program to create a class Counter that keeps track of how many objects
24 KEERTHI VASAN P
Q3 have been created using a constructor, and prints a message when an object is
destroyed using a destructor.
Write a C++ program to create a class Complex with private attributes real and
Q4 imaginary. Define a friend function addComplex() to add two complex numbers and
another friend function subtractComplex() to subtract two complex numbers.
Q4 Define a friend function displayBookDetails() that takes two Book objects and
displays their details.
Q1 Write a C++ program to find the largest and smallest elements in an array.
Write a C++ program to create a class NumberOperations with a method
Q2
reverseNumber() that reverses a given number.
Write a C++ program to create a class Greeting that displays a welcome message
Q3 when an object of the class is created (using the constructor) and another message
26 LATHISHARAN R
when the object is destroyed (using the destructor).
Write a C++ program to define two classes Car and Engine. The Car class has private
attributes carModel and carColor, and the Engine class has private attributes
Q4
engineType and horsePower. Define the Engine class as a friend of the Car class to
access and display the car's details.
Write a C++ program to find the missing number in an array containing numbers from
Q1
1 to n.
Write a C++ program to create a class Number with a method checkEvenOdd() that
Q2
checks whether a number is even or odd.
Write a C++ program to define a class Time with attributes hours, minutes, and
27 MONISH D
Q3 seconds. Use a constructor to initialize these attributes and display the time in the
format "HH:MM:SS".
Write a C++ program to create a class Box with private attributes length, width, and
Q3 a constructor to initialize these values and a destructor to print a message when the
object is destroyed. Also, include a method to calculate the area of the rectangle.
Write a C++ program to create two classes ClassA and ClassB, where both classes
Q4 have private attributes. Define a third class ClassC as a friend of both ClassA and
ClassB to access and display the private attributes of both classes.
Q1 Write a C++ program to check whether a given year is a leap year or not.
Write a C++ program that defines a class Temperature with a method
Q2
convertToFahrenheit() that converts a given temperature in Celsius to Fahrenheit.
Write a C++ program to define a class Item with attributes itemName and itemPrice.
31 MUTHARASI R Q3 Use a constructor to initialize these attributes when an object of Item is created, and
display the item details.
Write a C++ program that defines a class Student with private attributes name and
Q4 marks. Define another class Result as a friend of the Student class to access and
display the student's marks.
Q4 and seconds. Define a friend function addTime() that adds two Time objects and
returns the sum of both times.
Q1 Write a C++ program to calculate the square root of a number using the sqrt function.
Write a C++ program to create two objects of the class Person, each with different
Q2
values for name and age. Display the details of both objects
Write a C++ program to define a class Account with a private attribute balance.
33 NITHILESH A Q3 Implement a constructor to initialize the balance and a destructor to display a message
when the object is destroyed (e.g., "Account is closed").
Write a C++ program to create a class ComplexNumber with private attributes real
Q4 and imaginary. Define a friend function addComplex() to add two complex numbers
and return the result.
Write a C++ program to create a simple calculator that performs addition, subtraction,
Q1
multiplication, and division using functions.
Write a C++ program to define a class Account with an attribute balance. Implement a
Q2 constructor to initialize the balance and a destructor to display a message when the
object is destroyed.
34 NIVARTHI C Write a C++ program to create a class Student with attributes name, rollNumber, and
Q3 marks. Implement constructor overloading to initialize the object with different sets of
parameters.
Write a C++ program to define a class Point with private attributes x and y. Define a
Q4 friend function comparePoints() to compare two Point objects and return whether they
are equal or not based on their coordinates.
Write a C++ program to pass an array to a function and find the sum of all the
35 PREETH RAJ M Q1
elements.
Write a C++ program to create a class Student with private attributes name and age.
Q2
Implement getter and setter functions to access and modify these attributes.
Write a C++ program to define a class Car with attributes make, model, and year. Use
Q3
a parameterized constructor to initialize these attributes when the object is created.
Write a C++ program to create a class Number with private attribute value. Define a
Q4
friend function swapValues() to swap the values of two Number objects.
Q3 a default constructor to initialize these attributes to default values (e.g., 0). Display the
36 PRIYADHARSHINI M
dimensions of the rectangle.
Write a C++ program that defines two classes: Person and Address. The Address class
has private attributes street, city, and zipCode, and the Person class has private
Q4
attributes name and age. Define a friend function displayDetails() that can access and
display both Person and Address details.
Q2 Create member functions to set the values of these attributes and calculate the area
37 PRIYADHARSHINI S
and perimeter.
Write a C++ program to create a class Person with attributes name and age. Use a
Q3
constructor to initialize these attributes and display the details of the object.
Write a C++ program to create a class Box with private attributes length, width, and
Q4 height. Write a friend function setDimensions() to modify the private attributes of the
Box object
Q4 and balance. Write a friend function displayBalance() to access and display the
account balance.
Q4 width. Define a friend function calculateArea() that calculates and displays the area of
the rectangle.
Q4 friend function distance() that calculates and returns the distance between two Point
objects using the distance formula.
Q1 Write a C++ program to calculate the factorial of a given number using a loop.
Write a C++ program to define a class Person with attributes like name and age.
Q2
Create an object of Person and display the name and age.
Write a C++ program to create a class Book with attributes title and price. Use a copy
41 REVATHI E Q3 constructor to initialize one Book object from another Book object and display the
details of the new object.
Write a C++ program to define a class Product with private attributes productName
Q4 and price. Define a friend function applyDiscount() that calculates and displays the
price after a discount is applied.
Write a C++ program to check if a number is a palindrome or not (a number that reads
Q1
the same forward and backward).
42 RUBESHKUMAR A Write a C++ program to create a class BankAccount with methods to calculate and
Q4 width. Define a friend function findMaxArea() that compares two Rectangle objects
and returns the one with the larger area.
Q4 imaginary. Define a friend function addComplex() to add two complex numbers and
another friend function subtractComplex() to subtract two complex numbers.
Q1 Write a C++ program to find the sum of the digits of a given number.
Write a C++ program to create a class NumberOperations with a method
Q2
reverseNumber() that reverses a given number.
Write a C++ program to create a class Greeting that displays a welcome message
Q3 when an object of the class is created (using the constructor) and another message
45 SHARUBALA C
when the object is destroyed (using the destructor).
Write a C++ program to define two classes Car and Engine. The Car class has private
attributes carModel and carColor, and the Engine class has private attributes
Q4
engineType and horsePower. Define the Engine class as a friend of the Car class to
access and display the car's details.
Write a C++ program to check if a given number is an Armstrong number (a number
Q1
that is equal to the sum of the cubes of its digits).
Write a C++ program to create a class Number with a method checkEvenOdd() that
Q2
checks whether a number is even or odd.
Write a C++ program to define a class Time with attributes hours, minutes, and
46 SHREETHAR R
Q3 seconds. Use a constructor to initialize these attributes and display the time in the
format "HH:MM:SS".
Write a C++ program to create a class Box with private attributes length, width, and
Q4 have private attributes. Define a third class ClassC as a friend of both ClassA and
ClassB to access and display the private attributes of both classes.
Write a C++ program to convert temperature from Celsius to Fahrenheit and vice
Q1
versa.
49 SRI PRASANNA R
Write a C++ program to create a class Student with attributes like name, rollNumber,
Q2
and marks. Create methods to input the data and display it.
Write a C++ program to create a class Employee with attributes name and salary. Use
Q3
a constructor to initialize an array of Employee objects and display their details.
Write a C++ program to define two classes: Employee and Department. The
Department class has private attributes departmentName and employeeCount, while
Q4
the Employee class has private attributes employeeName and salary. Define a friend
function showDetails() that can access and display details of both classes.
Q1 Write a C++ program to print all prime numbers between two numbers.
Write a C++ program that defines a class Temperature with a method
Q2
convertToFahrenheit() that converts a given temperature in Celsius to Fahrenheit.
Write a C++ program to define a class Item with attributes itemName and itemPrice.
Q3 Use a constructor to initialize these attributes when an object of Item is created, and
50 SUBASHINI B
display the item details.
Write a C++ program to define two classes: Library with private attributes bookTitle
and author, and Member with a private attribute memberName. Define a friend class
Q4
Transaction that can access the private data of both Library and Member to record and
display a book transaction.
Q1 Write a C++ program to find the greatest common divisor of two numbers.
Write a C++ program to create a class Number with two integer attributes. Create a
Q2
method findGreater() to find and display the greater of the two numbers.
51 SUDHAHAR T
Write a C++ program to define a class Library with attributes name and location. Use
Q4 marks. Define another class Result as a friend of the Student class to access and
display the student's marks.
Q1 Write a C++ program to find the least common multiple of two numbers.
Write a C++ program to create two objects of the class Person, each with different
Q2
values for name and age. Display the details of both objects.
Write a C++ program to define a class Account with a private attribute balance.
52 TAMILMARAN K Q3 Implement a constructor to initialize the balance and a destructor to display a message
when the object is destroyed (e.g., "Account is closed").
Write a C++ program to define a class Time with private attributes hours, minutes,
Q4 and seconds. Define a friend function addTime() that adds two Time objects and
returns the sum of both times.
Q2 constructor to initialize the balance and a destructor to display a message when the
object is destroyed.
Write a C++ program to create a class Student with attributes name, rollNumber, and
53 THARANI B S
Q3 marks. Implement constructor overloading to initialize the object with different sets of
parameters.
Write a C++ program to create a class ComplexNumber with private attributes real
Q4 and imaginary. Define a friend function addComplex() to add two complex numbers
and return the result.
Q1 Write a C++ program to find the transpose of a matrix.
Write a C++ program to create a class Student with private attributes name and age.
Q2
Implement getter and setter functions to access and modify these attributes.
Write a C++ program to define a class Car with attributes make, model, and year. Use
THIRUVARULSELVAN
54 Q3
K a parameterized constructor to initialize these attributes when the object is created.
Write a C++ program to define a class Point with private attributes x and y. Define a
Q4 friend function comparePoints() to compare two Point objects and return whether they
are equal or not based on their coordinates.
Q1 Write a C++ program to count the number of vowels and consonants in a string.
Write a C++ program to define a class Car with attributes make and model. Use a
Q2
default constructor to initialize these attributes and display the car details.
Write a C++ program to define a class Rectangle with attributes length and width. Use
55 VIDHYASHREE N
Q3 a default constructor to initialize these attributes to default values (e.g., 0). Display the
dimensions of the rectangle.
Write a C++ program to create a class Number with private attribute value. Define a
Q4
friend function swapValues() to swap the values of two Number objects.
Q1 Write a C++ program to reverse a string without using any built-in functions.
Write a C++ program to define a class Rectangle with attributes length and width.
Q2 Create member functions to set the values of these attributes and calculate the area
56 VISHWANATH S
and perimeter.
Write a C++ program to create a class Person with attributes name and age. Use a
Q3
constructor to initialize these attributes and display the details of the object.
Write a C++ program that defines two classes: Person and Address. The Address class
has private attributes street, city, and zipCode, and the Person class has private
Q4
attributes name and age. Define a friend function displayDetails() that can access and
display both Person and Address details.
Q4 height. Write a friend function setDimensions() to modify the private attributes of the
Box object.
Q1 Write a C++ program to find the length of a string without using built-in functions.
Write a C++ program to create a class Calculator with a member function add() that
Q2
takes two integers as input and returns their sum.
Write a C++ program to create a class ComplexNumber with attributes real and
58 VARSHA K Q3 imaginary. Use a constructor to initialize these values and a destructor to print a
message when the object is destroyed
Write a C++ program to create a class Account with private attributes accountNumber
Q4 and balance. Write a friend function displayBalance() to access and display the
account balance.
Write a C++ program to count how many times a particular character appears in a
Q1
string.
Write a C++ program to define a class Book with attributes like title, author, and
Q2
price. Initialize these values using a constructor and display them.
Write a C++ program that defines a class Employee with attributes employeeName
59 VETHIKA G
Q3 and employeeID. Use a constructor to initialize these values and a destructor to
display a message when an object of the Employee class is destroyed.
Write a C++ program to define a class Rectangle with private attributes length and
Q4 width. Define a friend function calculateArea() that calculates and displays the area of
the rectangle.
Q4 friend function distance() that calculates and returns the distance between two Point
objects using the distance formula.