Answer to Question #350044 in C++ for fiona

Question #350044

create a c++ program with a function named “area” that calculates the area of a rectangle and function named “perimeter”that calculates perimeter of rectangle. Let the user input the data needed for the program.


1
Expert's answer
2022-06-13T08:27:08-0400
#include <iostream>
using namespace std;

int area(int length, int width);
int perimeter(int length, int width);

int main()
{
    int length, width;
    cout << "Enter length: ";
    cin >> length;
    cout << "Enter width: ";
    cin >> width;
    cout << "\nArea: " << area(length, width) << "\n";
    cout << "Perimeter: " << perimeter(length, width) << endl;
}

int area(int length, int width) {
    return length * width;
}

int perimeter(int length, int width) {
    return (length + width) * 2;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS