โ Back to Functions/Methods
Question 295
Function: Clamp a Value
Function: Clamp a Value
Write a functionclamp(int x, int lo, int hi)that returnsloifxis below the range,hiifxis above it, andxotherwise. Read a value from input and clamp it to the range10to20. For input5the output is: 10 Print the clamped value with%d.
Expected Output:
10
Topics:
Functions/Methods
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.