From 8597b29e143cdeae50eafae06e0d8ed900b25295 Mon Sep 17 00:00:00 2001 From: anand Date: Tue, 18 Nov 2025 22:40:54 +0530 Subject: Completed till exercise 4 --- exercises/01_variables/variables1.rs | 2 +- exercises/01_variables/variables2.rs | 2 +- exercises/01_variables/variables3.rs | 2 +- exercises/01_variables/variables4.rs | 2 +- exercises/01_variables/variables5.rs | 2 +- exercises/01_variables/variables6.rs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'exercises/01_variables') diff --git a/exercises/01_variables/variables1.rs b/exercises/01_variables/variables1.rs index f83b44d..ec1bcac 100644 --- a/exercises/01_variables/variables1.rs +++ b/exercises/01_variables/variables1.rs @@ -1,6 +1,6 @@ fn main() { // TODO: Add the missing keyword. - x = 5; + let x = 5; println!("x has the value {x}"); } diff --git a/exercises/01_variables/variables2.rs b/exercises/01_variables/variables2.rs index e2a3603..e2fd5d0 100644 --- a/exercises/01_variables/variables2.rs +++ b/exercises/01_variables/variables2.rs @@ -1,6 +1,6 @@ fn main() { // TODO: Change the line below to fix the compiler error. - let x; + let x = 10; if x == 10 { println!("x is ten!"); diff --git a/exercises/01_variables/variables3.rs b/exercises/01_variables/variables3.rs index 06f35bb..45a8586 100644 --- a/exercises/01_variables/variables3.rs +++ b/exercises/01_variables/variables3.rs @@ -1,6 +1,6 @@ fn main() { // TODO: Change the line below to fix the compiler error. - let x: i32; + let x: i32 = 10; println!("Number {x}"); } diff --git a/exercises/01_variables/variables4.rs b/exercises/01_variables/variables4.rs index 6c138b1..90d4ef0 100644 --- a/exercises/01_variables/variables4.rs +++ b/exercises/01_variables/variables4.rs @@ -1,6 +1,6 @@ // TODO: Fix the compiler error. fn main() { - let x = 3; + let mut x = 3; println!("Number {x}"); x = 5; // Don't change this line diff --git a/exercises/01_variables/variables5.rs b/exercises/01_variables/variables5.rs index cf5620d..085e099 100644 --- a/exercises/01_variables/variables5.rs +++ b/exercises/01_variables/variables5.rs @@ -3,6 +3,6 @@ fn main() { println!("Spell a number: {number}"); // TODO: Fix the compiler error by changing the line below without renaming the variable. - number = 3; + let number = 3; println!("Number plus two is: {}", number + 2); } diff --git a/exercises/01_variables/variables6.rs b/exercises/01_variables/variables6.rs index 4a040fd..deb33ed 100644 --- a/exercises/01_variables/variables6.rs +++ b/exercises/01_variables/variables6.rs @@ -1,5 +1,5 @@ // TODO: Change the line below to fix the compiler error. -const NUMBER = 3; +const NUMBER: i32 = 3; fn main() { println!("Number: {NUMBER}"); -- cgit v1.2.3