mobile typing isn't scored — practice only
template <typename T>
C++ · general · type the snippet below to practice
def fib(n):
a, b = 0, 1
for _ in range(n):
a, b = b, a + b
return a
about this snippet
This is the template snippet in C++ — 12 lines of real C++ code that exercises common patterns you'll see in production. DeveloperType scores you on net WPM and accuracy and only counts runs above 95% accuracy on the leaderboard, so practice rewards precision, not speed alone.
view source (12 lines)
template <typename T>
T clamp(T val, T lo, T hi) {
return (val < lo) ? lo : (val > hi) ? hi : val;
}
template <typename Container>
typename Container::value_type sum(const Container& c) {
typename Container::value_type total{};
for (const auto& x : c) total += x;
return total;
}
more C++ snippets:
browse all C++ snippets →