Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- struct circle
- {
- float radius;
- float diameter;
- };
- struct square
- {
- float side;
- };
- struct rectangle
- {
- float length;
- float width;
- };
- struct triangle
- {
- float base;
- float height;
- };
- char choice;
- struct circle circle;
- struct square square;
- struct rectangle rectangle;
- struct triangle triangle;
- cin >> choice;
- switch(choice)
- {
- case 'C':
- cout << "Enter radius: ";
- cin >> circle.radius;
- cout << 3.14 * (circle.radius * circle.radius) << endl;
- break;
- case 'S':
- cout << "Enter side: ";
- cin >> square.side;
- cout << square.side * square.side;
- break;
- case 'R':
- cout << "Enter length: ";
- cin >> rectangle.length;
- cout << "Enter width: ";
- cin >> rectangle.width;
- cout << rectangle.length * rectangle.width;
- break;
- case 'T':
- cout << "Enter base: ";
- cin >> triangle.base;
- cout << "Enter height: ";
- cin >> triangle.height;
- cout << 0.5 * (triangle.base * triangle.height);
- break;
- default:
- cout << "Invalid Entry" << endl;
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement