How to calculate the volume of cylinder in Rust

1 Answer

0 votes
fn main() {
    let radius:f32 = 12.0;
    let height:f32 = 26.0;
    
    let pi:f32 = std::f32::consts::PI;
    
    let cylinder_volume:f32 = pi * (radius * radius) * height;
    
    println!("Cylinder volume = {}", cylinder_volume);
}



/*
run:
   
Cylinder volume = 11762.123
   
*/

 



answered May 10, 2023 by avibootz

Related questions

1 answer 132 views
1 answer 90 views
1 answer 144 views
1 answer 126 views
1 answer 145 views
1 answer 162 views
1 answer 103 views
...