functions

This commit is contained in:
Pinklady01 2021-04-13 15:32:53 +02:00
parent 31ae44d7ca
commit 261736a355
4 changed files with 6 additions and 11 deletions

View file

@ -1,13 +1,12 @@
// functions2.rs
// Make me compile! Execute `rustlings hint functions2` for hints :)
// 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);
}

View file

@ -1,10 +1,9 @@
// functions3.rs
// Make me compile! Execute `rustlings hint functions3` for hints :)
// I AM NOT DONE
fn main() {
call_me();
call_me(5);
}
fn call_me(num: u32) {

View file

@ -4,18 +4,16 @@
// This store is having a sale where if the price is an even number, you get
// 10 Rustbucks off, but if it's an odd number, it's 3 Rustbucks off.
// 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
return price - 10
} else {
price - 3
return price - 3
}
}

View file

@ -1,7 +1,6 @@
// functions5.rs
// Make me compile! Execute `rustlings hint functions5` for hints :)
// I AM NOT DONE
fn main() {
let answer = square(3);
@ -9,5 +8,5 @@ fn main() {
}
fn square(num: i32) -> i32 {
num * num;
return num * num;
}