Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- using namespace std;
- struct circle
- {
- float radius;
- };
- struct rectangle
- {
- float length, width;
- };
- struct square
- {
- float length;
- };
- #include <iomanip>
- double areacircle(float radius);
- double arearectangle(float length,float width );
- double areasquare(float slength);
- void perirec(float &length, float &width);
- double cost1(float &peri, float uni);
- int main()
- {
- float length=0, width=0;
- struct circle c;
- struct rectangle r1, r2;
- struct square s1;
- float uni, cost;
- c.radius = 5;
- r1.length = 7;
- r1.width = 3;
- s1.length = 4;
- r2.length = 28;
- r2.width = 15;
- double yard = r2.length * r2.width;
- double cir=areacircle(c.radius);
- double rec=arearectangle(r1.length, r1.width);
- double sq=areasquare(s1.length);
- double garea = yard - (cir + rec + sq);
- cout << "The green color area is " << setiosflags(ios::fixed)
- << setprecision(2)<< garea;
- perirec( length, width);
- float peri = (length * 2) + (width * 2);
- cout << "Enter the cost per unit ";
- cin >> uni;
- cost = cost1(peri, uni);
- cout <<"THe total cost for the fence is "<< setiosflags(ios::fixed)
- << setprecision(2) << cost;
- }
- double areacircle(float radius)
- {
- return 22 / 7 * radius*radius;
- }
- double arearectangle(float length, float width)
- {
- return length * width;
- }
- double areasquare(float slength)
- {
- return slength * slength;
- }
- void perirec(float &length, float &width)
- {
- cout << "Enter the length ";
- cin >> length;
- cout << "Enter the width ";
- cin >> width;
- }
- double cost1(float &peri, float uni)
- {
- return uni * peri;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement