CodeTheRobot

C++ Beginner · exercise 03

Control flow & functions

Write a clamp function and apply it to a list of joint targets.

C++ Beginner lesson 03

Guided steps

  1. 1.Write double clamp(double value, double low, double high).
  2. 2.Loop over the three targets and print each clamped value with two decimals.
  3. 3.A safe clamp never returns a value outside the limits, even for inputs far outside them.

Your code

Your code is saved in this browser after every run and restored next time.