Rust program to calculate the area and circumference of a circle
kw.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
kodingwindow@kw:~$ rustc kw.rs
kodingwindow@kw:~$ ./kw ——————————————————————————————————————————— 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 ——————————————————————————————————————————— kodingwindow@kw:~$
Advertisement