mirror of
https://github.com/rust-lang/rustlings.git
synced 2025-06-15 00:04:58 +02:00
First quiz and its related modules
This commit is contained in:
@ -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!!!");
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user