Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Created by Tan
- // Program designed to output volume of a cylinder.
- // User is asked for value of Radius and Height, then Volume is output.
- // Formula used: V= pi*r^2*h
- // Pi = 3.14159265
- #include <iostream> // Needed for Cin Cout
- using namespace std;
- int main()
- {
- double d_Volume, d_Pi, d_Radius, d_Height; // Names of variables in our equations. Added a prefix of " d_ " to improve syntax highlighting.
- cout << "+++++++++++++++++++++++++++++++++++++++" << endl;
- cout << "Cylinder Volume Calculator by Tan" << endl;
- cout << "Input the radius and height of the cylinder whose volume you'd like calculated." << endl;
- cout << "Formula used: Volume = Pi*Radius^2*Height" << endl;
- cout << "Value of Pi is to 9 figures." << endl;
- cout << "+++++++++++++++++++++++++++++++++++++++" << endl;
- cout << "What is the radius of your cylinder?" << endl;
- cin >> d_Radius; // Radius is stored as a number
- cout << "What is the height of your cylinder?" << endl;
- cin >> d_Height; // Height is stored as a number
- d_Pi = 3.14159265;
- d_Volume = d_Pi*pow(d_Radius, 2) * d_Height;
- cout << "The volume of your cylinder is: " << d_Volume << endl;
- system("pause");
- return 0;
- }
- // Variables
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement