Write a C++ program implementing a custom forward iterator for a container class to enable range-based for loops.
First line: N. Second line: N space-separated integers.
Print container elements accessed via custom iterator in range-based for loop separated by a space.
1 <= N <= 100
5 10 20 30 40 50
10 20 30 40 50
Capstone project integrating custom iterator architecture to support modern range-based iteration.
#include <iostream>
class SimpleContainer {
private:
int arr[100];
int size;
public:
SimpleContainer(int n) : size(n) {}
void set(int idx, int val) {
arr[idx] = val;
}
class Iterator {
private:
int *ptr;
public:
Iterator(int *p) : ptr(p) {}
bool operator!=(const Iterator &other) const { return ptr != other.ptr; }
int& operator*() { return *ptr; }
// Implement increment operator++ here
};
// Implement begin() and end() methods here
};
int main() {
int n;
if (std::cin >> n) {
SimpleContainer sc(n);
for (int i = 0; i < n; i++) {
int val;
std::cin >> val;
sc.set(i, val);
}
bool first = true;
for (int val : sc) {
if (!first) std::cout << " ";
std::cout << val;
first = false;
}
std::cout << "n";
}
return 0;
}Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used