1
0
Fork 0
mirror of https://github.com/notohh/rustlings.git synced 2025-07-21 21:30:04 -04:00

First quiz and its related modules

This commit is contained in:
Nidhal Messaoudi 2023-02-26 17:28:24 +01:00
commit 52ed5dbcf9
22 changed files with 60 additions and 98 deletions

View file

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

View file

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

View file

@ -7,14 +7,12 @@
// 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) -> {
fn sale_price(price: i32) -> i32 {
if is_even(price) {
price - 10
} else {

View file

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