GitHub

Practice

Practice - 016

A program to explain SIMPLE IF

use text_io::scan;
fn main() {
practice16()
}
fn practice16() {
let age: i32;
println!("Enter age:");
scan!("{}", age);
if age > 18 {
println!("Eligible to vote");
}
}

Config

[package]
name = "practice"
version = "0.1.0"
edition = "2021"
[dependencies]
text_io = "0.1.12"

Result

Enter age:
12
Enter age:
45
Eligible to vote
Previous
Practice - 015