Complete the code to print "Hello, world!" using println! macro.
fn main() {
[1]!("Hello, world!");
}The println! macro prints text followed by a new line.
Complete the code to print the value of variable x using println! macro.
fn main() {
let x = 5;
println!("Value is: [1]", x);
}The placeholder {} is used to print variable values in println!.
Fix the error in the code to correctly print the sum of a and b.
fn main() {
let a = 3;
let b = 4;
println!("Sum is: [1]", a + b);
}The placeholder {} is needed to print the result of a + b.
Fill both blanks to print the name and age variables using println! macro.
fn main() {
let name = "Alice";
let age = 30;
println!("Name: [1], Age: [2]", name, age);
}Use {} placeholders for each variable in the string.
Fill all three blanks to print the uppercase name, age, and a greeting message.
fn main() {
let name = "Bob";
let age = 25;
println!("[1] is [2] years old. [3]!", name.to_uppercase(), age, "Hello");
}Use {} placeholders for each value. The first placeholder is for the uppercase name, so {name} is incorrect inside the string, but the argument name.to_uppercase() is passed.