A

Admin • 828.03K Points
Coach

Q. What is the output of this code?

Code:
fn main() {
let x = 10;
let y = &x;
println!("{}", y);
}
  • (A) 10
  • (B) &10
  • (C) Compilation error
  • (D) Memory address
  • Correct Answer - Option(A)
  • Views: 11
  • Filed under category Rust
  • Hashtags:

Explanation by: Admin
Rust automatically dereferences references in println!, so it prints 10.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.