Rectangle perimeter calculator

Report a typo

You're adding functionality to your geometry calculator. Write a C++ function named calculatePerimeter that has two overloaded versions:

  1. The first version takes the length and width of a rectangle as parameters and returns the perimeter of the rectangle.

  2. The second version takes the side length of a square as a parameter and returns the perimeter of the square.

Sample Input 1:

5 3

Sample Output 1:

16

Sample Input 2:

7.5 4.2

Sample Output 2:

23.4

Sample Input 3:

4

Sample Output 3:

16
Write a program in C++





Create a free account to access the full topic