-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathq-1.cpp
79 lines (59 loc) · 1.78 KB
/
q-1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//WAP to find area of a circle, a rectangle and a triangle, using concept of function overloading.
#include<iostream>
using namespace std;
//Function prototying for the function area.
float area(int);
float area(int,int);
float area(float,float);
//defining the area function.
//circle
float area(int r)
{
int l,b;
float r,bs,ht;
cout<<"Enter length and breadth of rectangle:"<<endl;
cin>>l>>b;
cout<<"Enter radius of circle:"<<endl;
cin>>r;
cout<<"Enter base and height of triangle:"<<endl;
cin>>bs>>ht;
cout<<"\nArea of rectangle is "<<area(l,b);
cout<<"\nArea of circle is "<<area(r);
cout<<"\nArea of triangle is "<<area(bs,ht);
}
//Triangle
float area(int b,int h)
{
return(0.5 * b * h);
}
//Rectangle
float area(float l,float b)
{
return (l * b);
}
int main()
{
return((bs*ht)/2.0);
}
case 2:
{
cout<<"\n enter the base & height of triangle : ";
cin>>b>>h;
cout<<"\n area of triangle is : "<<area(b,h);
break;
}
case 3:
{
cout<<"\n enter the length & bredth of rectangle : ";
cin>>l>>b;
cout<<"\n Area of rectangle : "<<area(l,b);
break;
}
case 4:
exit(0);
default:
cout<<"\n enter a valid choice ";
}
}while(ch!=4);
return 0;
}