Here's an example program that overloads the area() function to calculate the area of a triangle and a circle: #include <iostream> using namespace std; // Function to calculate area of triangle float area(float base, float height) { return 0.5 * base * height; } // Function to calculate area of circle float area(float radius) { return 3.14 * radius * radius; } int main() { float base, height, radius; // Read input for triangle cout << "Enter base and height of the triangle: "; cin >> base >> height; // Calculate and display area of triangle float tri_area = area(base, height); cout << "Area of triangle: " << tri_area << endl; // Read input for circle cout << "Enter radius of the circle: "; cin >> radius; // Calculate and display area of circle ...
This blog is about providing theory as well as simple executable codes of different programming languages such as java, C, C++, and web programming, etc. This blog will be helpful to the IT students to learn about programming.