Skip to content

Commit

Permalink
Merge pull request #2 from Joaopmorais/functions
Browse files Browse the repository at this point in the history
add functions exercises completed
  • Loading branch information
Joaopmorais committed Feb 16, 2024
2 parents 5d561e8 + 97291f6 commit 438ac65
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 12 deletions.
6 changes: 4 additions & 2 deletions exercises/02_functions/functions1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
// Execute `rustlings hint functions1` or use the `hint` watch subcommand for a
// hint.

// I AM NOT DONE

fn main() {
call_me();
}

fn call_me(){

}
4 changes: 1 addition & 3 deletions exercises/02_functions/functions2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
// Execute `rustlings hint functions2` or use the `hint` watch subcommand for a
// hint.

// I AM NOT DONE

fn main() {
call_me(3);
}

fn call_me(num:) {
fn call_me(num:i32) {
for i in 0..num {
println!("Ring! Call number {}", i + 1);
}
Expand Down
4 changes: 1 addition & 3 deletions exercises/02_functions/functions3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
// Execute `rustlings hint functions3` or use the `hint` watch subcommand for a
// hint.

// I AM NOT DONE

fn main() {
call_me();
call_me(13);
}

fn call_me(num: u32) {
Expand Down
3 changes: 1 addition & 2 deletions exercises/02_functions/functions4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
// Execute `rustlings hint functions4` or use the `hint` watch subcommand for a
// hint.

// I AM NOT DONE

fn main() {
let original_price = 51;
println!("Your sale price is {}", sale_price(original_price));
}

fn sale_price(price: i32) -> {
fn sale_price(price: i32) -> i32 {
if is_even(price) {
price - 10
} else {
Expand Down
3 changes: 1 addition & 2 deletions exercises/02_functions/functions5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
// Execute `rustlings hint functions5` or use the `hint` watch subcommand for a
// hint.

// I AM NOT DONE

fn main() {
let answer = square(3);
println!("The square of 3 is {}", answer);
}

fn square(num: i32) -> i32 {
num * num;
num * num
}

0 comments on commit 438ac65

Please sign in to comment.