A

Admin • 828.03K Points
Coach

Q. What is the output of this code?

Code:
fn main() {
let mut x = 5;
x += 1;
println!("{}", x);
}
  • (A) 5
  • (B) 6
  • (C) Compilation error
  • (D) Undefined
  • Correct Answer - Option(B)
  • Views: 6
  • Filed under category Rust
  • Hashtags:

Explanation by: Admin
The variable 'x' is mutable and incremented by 1, resulting in 6.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.