Practice ยท 1 of 2
std::optional divide
Implement std::optional<int> safe_divide(int a, int b): return the quotient when b != 0, and std::nullopt when b == 0. No exceptions, no sentinel ints.
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: optional and enum practice