Exercises

Exercise 1

Will the program compile? Why, or why not? If not, try to fix it.

Press + to interact
fn main() {
42
}

Exercise 2

Will the program compile? Why or why not? If not, try to fix it.

Press + to interact
fn main() {
println!("{}", 42)
}

Exercise 3

Q

What is the output of this program?

fn main() {
    let x = 5;
    {
        let x = 6;
        println!("First time: {}", x);
    }
    println!("Second time: {}", x);
}
A)

First time: 6

Second time: 6

B)

First time: 6

Second time: 5

C)

First time: 5

Second time: 5

Exercise 4

Add the ...

Access this course and 1400+ top-rated courses and projects.