1
0
Fork 0
mirror of https://github.com/notohh/rustlings.git synced 2025-08-12 22:03:36 -04:00

Original exercises

This commit is contained in:
Nidhal Messaoudi 2023-02-27 21:33:28 +01:00
commit 278a1f103b
27 changed files with 87 additions and 58 deletions

View file

@ -1,10 +1,8 @@
// functions1.rs
// Execute `rustlings hint functions1` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE
fn main() {
call_me();
}
fn call_me() {
println!("I'm Nidhal Messaoudi, a software developer going Rusty!!!");
}

View file

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

View file

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

View file

@ -7,12 +7,14 @@
// in the signatures for now. If anything, this is a good way to peek ahead
// to future exercises!)
// I AM NOT DONE
fn main() {
let original_price = 51;
println!("Your sale price is {}", sale_price(original_price));
}
fn sale_price(price: i32) -> i32 {
fn sale_price(price: i32) -> {
if is_even(price) {
price - 10
} else {

View file

@ -1,11 +1,13 @@
// functions5.rs
// 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 {
return num * num;
num * num;
}