forked from iot-lab-kiit/tasks.cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq-1.cpp
More file actions
91 lines (67 loc) · 2.1 KB
/
q-1.cpp
File metadata and controls
91 lines (67 loc) · 2.1 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
//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)
{
return(3.14 * r * r);
}
//Triangle
float area(int b,int h)
{
return(0.5 * b * h);
}
//Rectangle
float area(float l,float b)
{
return (l * b);
}
int main()
{
float b,h,r,l;
int ch;
do
{
cout<<"\n Enter.. to find \n";
cout<<"\n 1. Area of Circle";
cout<<"\n 2. Area of Triangle";
cout<<"\n 3. Area of Rectangle";
cout<<"\n 4. Exit from the program ";
cout<<"\n\n Enter Your Choice : ";
cin>>ch;
switch(ch)
{
case 1:
{
cout<<"\n enter the radius for circle: ";
cin>>r;
cout<<"\n area of circle is : "<<area(r);
break;
}
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;
}