My Blog

My WordPress Blog

My Blog

My WordPress Blog

Range-Based For Loop

This example illustrates how to use the range-based for loop introduced in C++11.

cppCopy code#include <iostream>
#include <vector>

int main() {
std::vector&lt;int&gt; numbers = {10, 20, 30, 40, 50};
// Using a range-based for loop
for (const auto&amp; num : numbers) {
    std::cout &lt;&lt; num &lt;&lt; " "; // Output: 10 20 30 40 50
}
std::cout &lt;&lt; std::endl;
return 0;
}
Range-Based For Loop

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top