Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
855 B
1
Indexable
Never
#include <iostream>
using namespace std;
double pie = 3.14159;

double calculateVolume1(double radius, double height){
  double volume;
  volume = pie * radius * radius * height;
  return volume;
}

double calculateVolume2(double &radius, double &height){
  double volume;
  volume = pie * radius * radius * height;
  return volume;
}

double calculateVolume3(const double &radius, const double &height){
  double volume;
  volume = pie * radius * radius * height;
  return volume;
}

int main() {
  double rad, hei;
  cout << "Enter Radius: " << endl;
  cin >> rad;
  cout << "Enter Height: " << endl;
  cin >> hei;
  cout << "Volume (by Value): " << calculateVolume1(rad,hei) << endl; 
  cout << "Volume: (by Reference)" << calculateVolume2(rad, hei) << endl;
  cout << "Volume: (by const Reference)" << calculateVolume3(rad, hei) << endl;
  return 0;
}