0% found this document useful (0 votes)
3 views

Untitled document (90)

The document contains a C++ program that defines a Geometry class with methods to calculate the area and circumference of geometric shapes including circles, rectangles, and triangles. It demonstrates the usage of these methods in the main function by calculating and printing the area and circumference for given dimensions. The program utilizes the M_PI constant for accurate calculations involving circles.

Uploaded by

shreyakage177
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Untitled document (90)

The document contains a C++ program that defines a Geometry class with methods to calculate the area and circumference of geometric shapes including circles, rectangles, and triangles. It demonstrates the usage of these methods in the main function by calculating and printing the area and circumference for given dimensions. The program utilizes the M_PI constant for accurate calculations involving circles.

Uploaded by

shreyakage177
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

#include<iostream>

#include<cmath>

class Geometry {

public:

// Function to calculate the area of a circle

double area(double radius) {

return M_PI * radius * radius;

} Practicalkida.com

// Function to calculate the circumference of a circle

double circumference(double radius) {

return 2 * M_PI * radius;

// Function to calculate the area of a rectangle

double area(double length, double breadth) {

return length * breadth;

// Function to calculate the area of a triangle

double area(double base, double height, char triangle) {

return 0.5 * base * height;

};
int main() {

Geometry g;

double radius = 5.0;

double length = 10.0, breadth = 6.0;

double base = 8.0, height = 4.0;

std::cout << "Area of Circle: " << g.area(radius) << std::endl;

Practicalkida.com
std::cout << "Circumference of Circle: " << g.circumference(radius) << std::endl;

std::cout << "Area of Rectangle: " << g.area(length, breadth) << std::endl;

std::cout << "Area of Triangle: " << g.area(base, height, 't') << std::endl;

return 0;

You might also like