Rust program to calculate the area and circumference of a circle
codeaft.rs
fnmain(){constPI:f32=3.14;letr=5;letr=rasf32;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
codeaft@codeaft:~$ rustc codeaft.rs codeaft@codeaft:~$ ./codeaft
———————————————————————————————————————————
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
———————————————————————————————————————————
codeaft@codeaft:~$
Dear User, Thank you for visitng Codeaft. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.