Answer to Question #211342 in C++ for Khojo

Question #211342

Write a c++ program to find; 

(I). the perimeter of rectangle.

(ii). the circumference of a circle.

Note;

 (1). all the programs must allow the user to make his input .

(2).both programs must have both comment using the single line comment or the multiple line comment to give description to both programs.


1
Expert's answer
2021-06-28T07:24:05-0400
#include <iostream>
#include <cmath>

using namespace std;

double perimeter(double a, double b) {
  return 2 * (a + b);
}

double circumference(double radius) {
  return 2 * math.pi * radius;
}

int main() 
{
  double a, b;
  cout << "Enter sides of a rectangle: (a, b)" << endl;
  cin >> a >> b;
  double r;
  cout << "Enter the radius of a circle:" << endl;
  cin >> r;
  cout << "P = 2 * (a + b) = " << perimeter(a, b) << endl;
  cout << "C = 2 * pi * r = " << circumference(r) << endl;
  return 0;
}

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