Answer to Question #255504 in C++ for charli24

Question #255504
The volume, v, and side surface area, s, of a cylinder are given by the formulas v= _r 2l s = 2_rl where r is the cylinder’s radius, and l is its length. Using these formulas, write a c++ program with a function named cylinder()that accepts a cylinder’s radius and length and returns its volume and side surface area. Only in main() function will display the volume and surface area. Cylinder () is use only for computations. Sample Output Enter the radius of
1
Expert's answer
2021-10-23T08:05:47-0400
#include <iostream>
#include <string>
using namespace std;


void cylinder(float radius,float length,float& area,float& volume){
	const float PI = 3.14159265359; 
	area=(2 * PI * radius * length );
	volume= PI * radius * length;
}
int main()  {  
	float radius, length, area,volume;  
	cout<<"Enter radius of the cylinder: ";  
	scanf("%f", &radius);
	cout<<"Enter length of the cylinder: ";  
	scanf("%f", &length);
	cylinder(radius,length,area,volume);  
	cout<<"Surface side surface area of the cylinder is "<<area<<"\n";  
	cout<<"Surface volume of the cylinder is "<<volume<<"\n";  


	cin>>radius;


	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