Add solutions to intro and variables

This commit is contained in:
mo8it
2024-05-21 01:47:57 +02:00
parent bde2524c3b
commit 0f4c42d54e
16 changed files with 109 additions and 40 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
// Make the code print a greeting to the world.
// TODO: Fix the code to print "Hello world!".
fn main() {
printline!("Hello there!")
printline!("Hello world!");
}
+3 -3
View File
@@ -1,6 +1,6 @@
// Make me compile!
fn main() {
// TODO: Add missing keyword.
x = 5;
println!("x has the value {}", x);
println!("x has the value {x}");
}
+2
View File
@@ -1,5 +1,7 @@
fn main() {
// TODO: Change the line below to fix the compiler error.
let x;
if x == 10 {
println!("x is ten!");
} else {
+3 -1
View File
@@ -1,4 +1,6 @@
fn main() {
// TODO: Change the line below to fix the compiler error.
let x: i32;
println!("Number {}", x);
println!("Number {x}");
}
+6 -3
View File
@@ -1,6 +1,9 @@
// TODO: Fix the compiler error.
fn main() {
let x = 3;
println!("Number {}", x);
x = 5; // don't change this line
println!("Number {}", x);
println!("Number {x}");
x = 5; // Don't change this line
println!("Number {x}");
}
+6 -4
View File
@@ -1,6 +1,8 @@
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 = "T-H-R-E-E"; // Don't change this line
println!("Spell a number: {}", number);
// TODO: Fix the compiler error by changing the line below without renaming the the variable.
number = 3;
println!("Number plus two is: {}", number + 2);
}
+3 -1
View File
@@ -1,4 +1,6 @@
// TODO: Change the line below to fix the compiler error.
const NUMBER = 3;
fn main() {
println!("Number {}", NUMBER);
println!("Number: {NUMBER}");
}