Rust program to calculate the area and circumference of a circle
gd.rs
fn main()
{
    const PI:f32=3.14;
    let r=5;
    let r=r as f32;
    println!("———————————————————————————————————————————");
    println!("Program to calculate the area and circumference of a circle");
    println!("———————————————————————————————————————————");
    println!("The area of a circle is  {c}",c=PI*r*r);
    println!("The circumference of a circle is {c}",c=2.0*PI*r);
    println!("———————————————————————————————————————————");
}
Output
godarda@gd:~$ rustc gd.rs
godarda@gd:~$ ./gd ——————————————————————————————————————————— Program to calculate the area and circumference of a circle ——————————————————————————————————————————— The area of a circle is 78.5 The circumference of a circle is 31.400002 ——————————————————————————————————————————— godarda@gd:~$
Comments and Reactions