02_Functions Exercises completed!

This commit is contained in:
Faiizan Hussain 2023-11-30 19:50:08 +00:00
parent ccd816d57f
commit 06e5fd8ae2
5 changed files with 9 additions and 8 deletions

View File

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

View File

@ -3,13 +3,13 @@
// 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:u32) {
for i in 0..num {
println!("Ring! Call number {}", i + 1);
}

View File

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

View File

@ -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 {

View File

@ -11,5 +11,5 @@ fn main() {
}
fn square(num: i32) -> i32 {
num * num;
return num * num;
}