Docsity

C++ Programming Exercises: Classes and Objects, Exercises of Computer Science

Toggle sidebar
bg1
Write a Program to Find the Smallest and Largest Element in an Array.
Write a Program to Calculate the Sum of Elements in an Array.
Write a C++ program to implement a class called Circle that has private member variables for
radius. Include member functions to calculate the circle's area and circumference.
Write a C++ program to create a class called Rectangle that has private member variables for length
and width. Implement member functions to calculate the rectangle's area and perimeter.
Write a C++ program to create a class called Person that has private member variables for name,
age and country. Implement member functions to set and get the values of these variables.
Write a C++ program to create a class called Car that has private member variables for company,
model, and year. Implement member functions to get and set these variables.
Write a C++ program to implement a class called BankAccount that has private member variables
for account number and balance. Include member functions to deposit and withdraw money from
the account.
Write a C++ program to create a class called Triangle that has private member variables for the
lengths of its three sides. Implement member functions to determine if the triangle is equilateral,
isosceles, or scalene.
Write a C++ program to implement a class called Employee that has private member variables for
name, employee ID, and salary. Include member functions to calculate and set salary based on
employee performance.
Write a C++ program to implement a class called Date that has private member variables for day,
month, and year. Include member functions to set and get these variables, as well as to validate if
the date is valid.
Write a C++ program to implement a class called Student that has private member variables for
name, class, roll number, and marks. Include member functions to calculate the grade based on the
marks and display the student's information.
Write a C++ program to implement a class called Shape with virtual member functions for
calculating area and perimeter. Derive classes such as Circle, Rectangle, and Triangle from the
Shape class and override virtual functions accordingly.

Partial preview of the text

Download C++ Programming Exercises: Classes and Objects and more Exercises Computer Science in PDF only on Docsity!

Write a Program to Find the Smallest and Largest Element in an Array. Write a Program to Calculate the Sum of Elements in an Array. Write a C++ program to implement a class called Circle that has private member variables for radius. Include member functions to calculate the circle's area and circumference. Write a C++ program to create a class called Rectangle that has private member variables for length and width. Implement member functions to calculate the rectangle's area and perimeter. Write a C++ program to create a class called Person that has private member variables for name, age and country. Implement member functions to set and get the values of these variables. Write a C++ program to create a class called Car that has private member variables for company, model, and year. Implement member functions to get and set these variables. Write a C++ program to implement a class called BankAccount that has private member variables for account number and balance. Include member functions to deposit and withdraw money from the account. Write a C++ program to create a class called Triangle that has private member variables for the lengths of its three sides. Implement member functions to determine if the triangle is equilateral, isosceles, or scalene. Write a C++ program to implement a class called Employee that has private member variables for name, employee ID, and salary. Include member functions to calculate and set salary based on employee performance. Write a C++ program to implement a class called Date that has private member variables for day, month, and year. Include member functions to set and get these variables, as well as to validate if the date is valid. Write a C++ program to implement a class called Student that has private member variables for name, class, roll number, and marks. Include member functions to calculate the grade based on the marks and display the student's information. Write a C++ program to implement a class called Shape with virtual member functions for calculating area and perimeter. Derive classes such as Circle, Rectangle, and Triangle from the Shape class and override virtual functions accordingly.