Fundamentals10 / 15
Up next

Range-based for

#include <print>
#include <vector>

int main() {
    std::vector<int> nums{10, 20, 30};
    // const auto& avoids copying each element
    for (const auto& n : nums) {
        std::println("{}", n);
    }
}
What you're solving

iterate a container directly