Fix the Prompt
The code below should read two numbers and print their product (multiplication), but it has bugs. Fix them!
Hints:
- Each input needs its own
String::new(). - Don't forget
mutand&mut. - Remember to trim before parsing.
rust
use std::io;
fn main() {
let mut line1 = String::new();
io::stdin().read_line(&mut line1).unwrap();
let a: i32 = line1.trim().parse().unwrap();
io::stdin().read_line(&mut line1).unwrap();
let b: i32 = line1.trim().parse().unwrap();
println!("{}", a * b);
}