usestd::io::{self,Write};fnmain(){constPI:f32=3.14;letmutinput=String::new();println!("———————————————————————————————————————————");println!("Program to calculate the area and circumference of a circle");println!("———————————————————————————————————————————");print!("Enter the radius of a circle ");io::stdout().flush().ok();io::stdin().read_line(&mutinput).unwrap();letr:f32=input.trim().parse().unwrap();println!("The area of a circle is {a}",a=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
———————————————————————————————————————————
Enter the radius of a circle 5
The area of a circle is 78.5
The circumference of a circle is 31.400002
———————————————————————————————————————————
kodingwindow@kw:~$
Advertisement
Thank You
Dear User, Thank you for visitng Kodingwindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.
Dear User, We are grateful for your interest in the Kodingwindow Android app. We intend to soon make it available on the Google Play Store. Currently, Android versions 10 and up require manual apk installations. Would you like to get the app?