sicily 2075. 2.2 Computing the volume of a cylinder
Description
Write a program that reads in the radius and length of a cylinder and computes volume using the following formulas:
area = radius * radius * PI
volume = area * length
PI = 3.14159
Input
One line contains num1, num2 (both in double) represent the radius and length of a cyliner.
Output
The volume in one line.
Hint
use the following code for output:
cout << answer<< endl;
刷一题C++体会一下
1 #include<iostream> 2 #define PI 3.14159 3 using namespace std; 4 int main() 5 { 6 double a, r, answer, l; 7 8 cin >> r >> l; 9 answer = r*r*PI*l; 10 cout << answer<< endl; 11 return 0; 12 }