CJCoding With Joseph

Function: Clamp a Value

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:

10

Print the clamped value with %d.

Expected Output:

10
Topics:
Functions/Methods
๐Ÿ“ฅ Auto-Input:
5
This input is automatically fed to your program's stdin
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท 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.