-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathperimeter.cpp
More file actions
47 lines (28 loc) · 727 Bytes
/
perimeter.cpp
File metadata and controls
47 lines (28 loc) · 727 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
// Example program
#include <iostream>
using namespace std;
void getPerim(int& len, int& width);
//gets length and width from user, then calls computations function
void computePerim(int len, int width);
//computes perimeter
int perimeter = 0;
int main()
{
int length = 0, width = 0;
getPerim(length, width);
cout<<"Length = "<<length<<" width = "<<width<<" and perimeter = "<<perimeter;
return 0;
}
void getPerim(int& len, int& width)
{
cout<<"Enter length : ";
cin>>len;
cout<<endl<<"Enter width : ";
cin>>width;
cout<<endl;
computePerim(len, width);
}
void computePerim(int len, int width)
{
perimeter = (2 * len) + (2* width);
}