Answer to Question #263858 in C++ for Aashi

Question #263858

WAP to calculate and display the surface area of sphere and cylinder demonstrating the concept of function overloading

1
Expert's answer
2021-11-11T07:31:12-0500
#include<iostream>
#include<math.h>
using namespace std;


double pi=3.1415;
double volume(double r){
	double vol = (4/3) * pi * r * r* r;
	return vol;
}


double volume(double h,  double r){
	double vol = pi * r * r * h;
	return vol;
}




int main(){
	cout<<"Enter the radius of the sphere:\n";
	double rad;
	cin>>rad;
	cout<<"The volume of the sphere is :"<<volume(rad)<<endl;
	
	cout<<"Enter the radius of the cylinder\n";
	double r;
	cin>>r;
	cout<<"The height of the cylinder\n";
	double h;
	cin>>h;
	cout<<"The volume of the cylinder is :"<<volume(h,r)<<endl;
}

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