Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add functions exercises completed #2

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}