Skip to content

Commit

Permalink
Create Constant.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisIs-Developer authored Jan 10, 2024
1 parent 68fbef7 commit fcdc559
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions code/Constant.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
fn main()
{
// we cant use mut with const
// **we cant use small letters for const

const SECONDS_PER_MINUTE: u32 = 60; // we have to provide a type for the const
println!("{} seconds in a minute", SECONDS_PER_MINUTE);

const MINUTES_PER_HOUR: i32 = 60;
println!("{} minutes in an hour", MINUTES_PER_HOUR);

const HOURS_PER_DAY: f32 = 24.0;
println!("{} hours in a day", HOURS_PER_DAY);

const DAYS_PER_WEEK: f64 = 7.0;
println!("{} days in a week", DAYS_PER_WEEK);

const WEEKS_PER_YEAR: u64 = 52;
println!("{} weeks in a year", WEEKS_PER_YEAR);

const USER_LIMIT:i32 = 100;
const PI:f32 = 3.14;

println!("user limit is {}",USER_LIMIT);
println!("pi value is {}",PI);
}

0 comments on commit fcdc559

Please sign in to comment.