February 2022
Intermediate to advanced
140 pages
2h 28m
English
| Puzzle 2 | Non-standard Input |
| | use std::io::stdin; |
| | |
| | fn main() { |
| | println!("What is 3+2? Type your answer and press enter."); |
| | let mut input = String::new(); |
| | stdin() |
| | .read_line(&mut input) |
| | .expect("Unable to read standard input"); |
| | |
| | if input == "5" { |
| | println!("Correct!"); |
| | } else { |
| | println!("Incorrect!"); |
| | } |
| | } |
Guess the Output | |
|---|---|
|
|
Try to guess what the output is before moving to the next page. |
The program’s interaction will look something like the following:
| <= | What is ... |
Read now
Unlock full access