Variables completed

This commit is contained in:
Asad Ali 2023-05-31 15:08:53 +05:00
parent 5cd73078fc
commit be21c8ab71
6 changed files with 14 additions and 21 deletions

View File

@ -2,9 +2,7 @@
// Make me compile!
// Execute `rustlings hint variables1` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE
fn main() {
x = 5;
println!("x has the value {}", x);
let x = 5;
println!("x has the value {:?}", x);
}

View File

@ -1,10 +1,9 @@
// variables2.rs
// Execute `rustlings hint variables2` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE
fn main() {
let x;
let x: u32 = 0 ;
if x == 10 {
println!("x is ten!");
} else {

View File

@ -1,9 +1,7 @@
// variables3.rs
// Execute `rustlings hint variables3` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE
fn main() {
let x: i32;
println!("Number {}", x);
let x: i32 = 10;
println!("Number {:?}", x);
}

View File

@ -1,11 +1,10 @@
// variables4.rs
// Execute `rustlings hint variables4` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE
fn main() {
let x = 3;
println!("Number {}", x);
let mut x = 3;
println!("Number {:?}", x);
x = 5; // don't change this line
println!("Number {}", x);
println!("Number {:?}", x);
}

View File

@ -1,11 +1,12 @@
// variables5.rs
// Execute `rustlings hint variables5` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE
fn main() {
let number = "T-H-R-E-E"; // don't change this line
println!("Spell a Number : {}", number);
number = 3; // don't rename this variable
println!("Number plus two is : {}", number + 2);
{
let number = 3; // don't rename this variable
println!("Number plus two is : {}", number + 2);
}
}

View File

@ -1,9 +1,7 @@
// variables6.rs
// Execute `rustlings hint variables6` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE
const NUMBER = 3;
const NUMBER : u32 = 3;
fn main() {
println!("Number {}", NUMBER);
println!("Number {:?}", NUMBER);
}