-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathperimeter2.cpp
More file actions
55 lines (35 loc) · 888 Bytes
/
perimeter2.cpp
File metadata and controls
55 lines (35 loc) · 888 Bytes
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
// Choice Code 420
#include <iostream>
using namespace std;
void getPerim();
//gets length and width from user, then calls computation and output functions
int computePerim(int len, int width);
//computes perimeter
void outputPerim(int length, int width, int perimeter);
//outputs perimeter and both sides
int main()
{
getPerim();
return 0;
}
void getPerim()
{
int len, width, perimeter;
cout<<"Enter length : ";
cin>>len;
cout<<endl<<"Enter width : ";
cin>>width;
cout<<endl;
perimeter = computePerim(len, width);
outputPerim(len, width, perimeter);
}
int computePerim(int len, int width)
{
return (2 * len) + (2* width);
}
void outputPerim(int length, int width, int perimeter)
{
cout<<"length = "<<length<<endl;
cout<<"width = "<<width<<endl;
cout<<"perimeter = "<<perimeter;
}