Skip to content

Commit 84df162

Browse files
committed
completed till quiz2
1 parent 9d6892b commit 84df162

39 files changed

+183
-47
lines changed

exercises/02_functions/functions1.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33
fn main() {
44
call_me(); // Don't change this line
55
}
6+
7+
fn call_me() {
8+
println!("fasdfasdf");
9+
}

exercises/02_functions/functions2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// TODO: Add the missing type of the argument `num` after the colon `:`.
2-
fn call_me(num:) {
2+
fn call_me(num: u8) {
33
for i in 0..num {
44
println!("Ring! Call number {}", i + 1);
55
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
fn call_me(num: u8) {
2-
for i in 0..num {
3-
println!("Ring! Call number {}", i + 1);
2+
for i in 1..num {
3+
println!("Ring! Call number {}", i);
44
}
55
}
66

77
fn main() {
88
// TODO: Fix the function call.
9-
call_me();
9+
call_me(10);
1010
}

exercises/02_functions/functions4.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn is_even(num: i64) -> bool {
88
}
99

1010
// TODO: Fix the function signature.
11-
fn sale_price(price: i64) -> {
11+
fn sale_price(price: i64) -> i64{
1212
if is_even(price) {
1313
price - 10
1414
} else {

exercises/02_functions/functions5.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// TODO: Fix the function body without changing the signature.
22
fn square(num: i32) -> i32 {
3-
num * num;
3+
num * num
44
}
55

66
fn main() {

exercises/03_if/if1.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ fn bigger(a: i32, b: i32) -> i32 {
44
// Do not use:
55
// - another function call
66
// - additional variables
7+
if a > b {
8+
a
9+
}else {
10+
b
11+
}
712
}
813

914
fn main() {

exercises/03_if/if2.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
fn picky_eater(food: &str) -> &str {
33
if food == "strawberry" {
44
"Yummy!"
5+
} else if food == "potato"{
6+
"I guess I can eat that."
57
} else {
6-
1
8+
"No thanks!"
79
}
810
}
911

exercises/03_if/if3.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ fn animal_habitat(animal: &str) -> &str {
33
let identifier = if animal == "crab" {
44
1
55
} else if animal == "gopher" {
6-
2.0
6+
2
77
} else if animal == "snake" {
88
3
99
} else {
10-
"Unknown"
10+
-1
1111
};
1212

1313
// Don't change the expression below!

exercises/04_primitive_types/primitive_types1.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ fn main() {
99
// TODO: Define a boolean variable with the name `is_evening` before the `if` statement below.
1010
// The value of the variable should be the negation (opposite) of `is_morning`.
1111
// let …
12+
let is_evening = !is_morning;
1213
if is_evening {
1314
println!("Good evening!");
1415
}

exercises/04_primitive_types/primitive_types2.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ fn main() {
1818
// from a different language than your own, try an emoji 😉
1919
// let your_character = '';
2020

21+
let your_character = ' ';
22+
2123
if your_character.is_alphabetic() {
2224
println!("Alphabetical!");
2325
} else if your_character.is_numeric() {

0 commit comments

Comments
 (0)