Recall & Review
beginner
What does the
println! macro do in Rust?It prints text to the console followed by a new line, allowing you to display output to the user.
Click to reveal answer
beginner
How do you print a variable's value using
println!?Use curly braces
{} as a placeholder inside the string, and pass the variable after the comma. Example: println!("Value: {}", x);Click to reveal answer
beginner
What happens if you use
println! without any arguments?It prints an empty line (just a new line) to the console.
Click to reveal answer
intermediate
Can
println! print multiple variables? How?Yes, by using multiple placeholders
{} and passing variables in order. Example: println!("{} and {}", a, b);Click to reveal answer
intermediate
What is the difference between
print! and println! macros?print! prints text without adding a new line at the end, while println! adds a new line after printing.Click to reveal answer
What will
println!("Hello, {}!", "Rust"); output?✗ Incorrect
The placeholder
{} is replaced by the string "Rust", so it prints: Hello, Rust!Which macro adds a new line after printing?
✗ Incorrect
println! adds a new line after printing, unlike print!.How do you print two variables
a and b using println!?✗ Incorrect
Use placeholders for each variable and pass them in order.
What does
println!(); print?✗ Incorrect
It prints a blank line (just a new line).
Which of these is correct to print the value of variable
x?✗ Incorrect
Use
{} as a placeholder and pass the variable after the comma.Explain how to use the
println! macro to print text and variables in Rust.Think about how you combine text and values inside the macro.
You got /4 concepts.
What is the difference between
print! and println! macros? When would you use each?Consider how output appears on the console.
You got /4 concepts.