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.
#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;
}
Comments
Leave a comment