-
-
Save Najaf/873ee221569a82e069bceae1cdd319d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io; | |
use std::io::Write; | |
fn prompt(question: &str) -> String { | |
let mut answer = String::new(); | |
print!("{}: ", question); | |
let _ = io::stdout().flush(); | |
let _ = io::stdin().read_line(&mut answer); | |
answer.trim().to_string() | |
} | |
fn main() { | |
let (first, second) = (prompt("First number").parse::<i32>().unwrap(), | |
prompt("Second number").parse::<i32>().unwrap()); | |
println!("{} + {} = {}", first, second, first + second); | |
println!("{} - {} = {}", first, second, first - second); | |
println!("{} * {} = {}", first, second, first * second); | |
println!("{} / {} = {}", first, second, first / second); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment