Code2pdf 66f86dea59c3c
Code2pdf 66f86dea59c3c
#include <iostream>
#include <cmath>
int main()
{
int choice;
float area,length,width,sides,rad;
cout << "Choose the shape you want to calculate the area for:\n";
cout << "1 for Circle\n";
cout << "2 for Rectangle\n";
cout << "3 for Cube\n";
cout << "Enter your choice here: ";
cin >> choice;
if (choice==1)
{
cout << "enter radius of the circle: " ;
cin >> rad ;
area = M_PI*rad*rad;
cout << "The area of the circle is: " << area << endl;
}
else if (choice==2)
{
cout<< "enter the length of rectangle:";
cin >> length;
cout << "Enter the width of rectangle:";
cin >> width;
area = length * width;
cout << "the area of rectangle is:" << area << endl;
}
else if (choice==3)
{
cout<< "enter the Sides of Cube:";
cin >> sides;
area = sides*sides*6;
cout << "The area of the cube is: " <<area;
}
else {
cout << "Invalid choice. Please enter a number between 1 to 3." << endl;
}
return 0;
}