Compute the Volume of a Cylinder

less than 1 minute read

The code has been modified slightly and now uploaded to the site.

Question

<— Return Home

22.cpp

#include <iostream>
using namespace std;

int main(){
    double area;
    double volume;
    double radius;
    double length;
    const double PI = 3.14159; //const?!! You mean final?!

    std::cout << "Enter radius and length of a cylinder: \n";
    std::cin >> radius;
    std::cin >> length;

    area = radius * radius * PI;
    volume = area * length;

    std::cout << "The area is " << area << "\n";
    std::cout << "The volume is " << volume << "\n";
}

<— Return Home