Exerpad
🔥0
0 XP
Lv.1 Beginner
Log In

Fix the Comparison

This program reads a score from input and checks if a student passed or failed, but the comparison operators are wrong!

A student passes if their score is 70 or above. Fix the comparison operators so the program works correctly.

Hint: Think carefully about which direction the comparison should go. Is < the same as >=?

rust
use std::io;

fn main() {
let mut input = String::new();
io::stdin().read_line(&mut input).unwrap();
let score: i32 = input.trim().parse().unwrap();

if score < 70 {
println!("You passed!");
} else {
println!("You failed.");
}
}