functions done

This commit is contained in:
David E. Perez Negron R. 2023-10-25 19:55:59 -06:00
parent 42fbe4e178
commit 9c58757b42
5 changed files with 6 additions and 9 deletions

View File

@ -3,8 +3,9 @@
// Execute `rustlings hint functions1` or use the `hint` watch subcommand for a // Execute `rustlings hint functions1` or use the `hint` watch subcommand for a
// hint. // hint.
// I AM NOT DONE
fn main() { fn main() {
call_me(); call_me();
} }
fn call_me(){}

View File

@ -3,13 +3,12 @@
// Execute `rustlings hint functions2` or use the `hint` watch subcommand for a // Execute `rustlings hint functions2` or use the `hint` watch subcommand for a
// hint. // hint.
// I AM NOT DONE
fn main() { fn main() {
call_me(3); call_me(3);
} }
fn call_me(num:) { fn call_me(num: isize) {
for i in 0..num { for i in 0..num {
println!("Ring! Call number {}", i + 1); println!("Ring! Call number {}", i + 1);
} }

View File

@ -3,10 +3,9 @@
// Execute `rustlings hint functions3` or use the `hint` watch subcommand for a // Execute `rustlings hint functions3` or use the `hint` watch subcommand for a
// hint. // hint.
// I AM NOT DONE
fn main() { fn main() {
call_me(); call_me(5);
} }
fn call_me(num: u32) { fn call_me(num: u32) {

View File

@ -8,14 +8,13 @@
// Execute `rustlings hint functions4` or use the `hint` watch subcommand for a // Execute `rustlings hint functions4` or use the `hint` watch subcommand for a
// hint. // hint.
// I AM NOT DONE
fn main() { fn main() {
let original_price = 51; let original_price = 51;
println!("Your sale price is {}", sale_price(original_price)); println!("Your sale price is {}", sale_price(original_price));
} }
fn sale_price(price: i32) -> { fn sale_price(price: i32) -> i32 {
if is_even(price) { if is_even(price) {
price - 10 price - 10
} else { } else {

View File

@ -3,7 +3,6 @@
// Execute `rustlings hint functions5` or use the `hint` watch subcommand for a // Execute `rustlings hint functions5` or use the `hint` watch subcommand for a
// hint. // hint.
// I AM NOT DONE
fn main() { fn main() {
let answer = square(3); let answer = square(3);
@ -11,5 +10,5 @@ fn main() {
} }
fn square(num: i32) -> i32 { fn square(num: i32) -> i32 {
num * num; num * num
} }