Answer to Question #27920 in C++ for red rose

Question #27920
The surface area, s, of a cylinder is given by the formula s = 2πrl where r is the cylinder’s radius and l its length. Using this formula, write a C++ function named surfarea() that accepts the radius and length of a cylinder and returns its surface. Make sure your function is called from main() and correctly returns a value to main(). Have main() use a cout statement to display the value returned.
Expert's answer
#include <cmath>
#include <iostream>

using namespace std;

double surfarea(double r, double l) {
return 2 * M_PI * r * l;

int main() {
double r, l;
cout << "Input the radius and length of cylinder." << endl;
cin >> r >> l;
double s = surfarea(r, l);
cout << "The surface area is " << s << "." << 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!


No comments. Be first!

Leave a comment

Ask Your question

New on Blog