Positive input
Input
abs_value(7)
Output
7
7 is already non-negative, so return 7.
Full lesson preview
Compute the absolute value of a number using conditional logic (no built-in abs()).
Problem statement
Task
Examples
Input
abs_value(7)
Output
7
7 is already non-negative, so return 7.
Input format
Output format
Constraints
Samples
Input
abs_value(-3)
Output
3
Absolute value of -3 is 3.