forked from 0x-r4bbit/intro-to-rust
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
5. Create and use functions, 6. Simple error handling with expect()
#3
Projects
Comments
prophen
changed the title
5. Create and use functions
5. Create and use functions, 6. Simple error handling with Jan 23, 2020
expect()
use std::io;
fn main() {
println!("Please enter the first number: ");
let mut first = String::new();
io::stdin().read_line(&mut first).unwrap();
let a: u32 = first.trim().parse().expect("Not a number");
println!("Please enter the second number: ");
let mut second = String::new();
io::stdin().read_line(&mut second).unwrap();
let b: u32 = second.trim().parse().expect("Not a number");
let result = sum(a, b);
println!("Result: {}", result);
}
fn sum(a: u32, b:u32 ) -> u32 {
a + b
} |
next issue #7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/prophen/intro-to-rust/blob/nikema's-notes/exercises/05.md
https://github.com/prophen/intro-to-rust/blob/nikema's-notes/exercises/06.md
The text was updated successfully, but these errors were encountered: