The source code to calculate the surface area, volume of the Cone is given below. The given program is compiled and executed successfully.
// Rust program to calculate
// the surface area, volume of Cone
use std::io;
fn main()
{
let mut height:f32 =0.0;
let mut radius:f32 =0.0;
let mut area:f32 =0.0;
let mut volume:f32 =0.0;
let mut input1 = String::new();
let mut input2 = String::new();
println!("Enter height: ");
io::stdin().read_line(&mut input1).expect("Not a valid string");
height = input1.trim().parse().expect("Not a valid number");
println!("Enter radius: ");
io::stdin().read_line(&mut input2).expect("Not a valid string");
radius = input2.trim().parse().expect("Not a valid number");
volume = (1.0 / 3.0) * (3.14) * radius * radius * height;
area = (3.14) * radius * (radius + (radius * radius + height * height).sqrt());
println!("Volume of Cone : {}", volume);
println!("Surface area of Cone: {}", area);
}
Output:
RUN 1:
Enter height:
2.5
Enter radius:
1.2
Volume of Cone : 3.7680006
Surface area of Cone: 14.970586
RUN 2:
Enter height:
12.4
Enter radius:
25.6
Volume of Cone : 8505.699
Surface area of Cone: 4344.3564
Explanation:
Here, we read the height, radius from the user. Then we calculated the surface area, volume of the Cone and printed the result.
Program/Source Code:
The source code to calculate the surface area, volume of the Cone is given below. The given program is compiled and executed successfully.
Output:
Explanation:
Here, we read the height, radius from the user. Then we calculated the surface area, volume of the Cone and printed the result.
need an explanation for this answer? contact us directly to get an explanation for this answer