CJCoding With Joseph
15free / daySign inCreate account

Write a function clamp(int x, int lo, int hi) that returns lo if x is below the range, hi if x is above it, and x otherwise. Read a value from input and clamp it to the range 10 to 20. For input 5 the output is exactly what is shown in Expected Output.

Print the clamped value with %d.

Expected output

10

= newline. No newline after the last line.

Hints3 available
Topics
Functions/Methods
Auto-input
5
This input is automatically fed to your program's stdin
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (p, fori)

Your output

Run your code to see the output here...

Test cases

Run your code to see test case results.