#include <iostream> using namespace std; namespace MathOps { int x = 10; int square(int n) { return n * n; } } int main() { cout << "x=" << MathOps::x << "\n"; cout << "Square=" << MathOps::square(MathOps::x) << "\n"; return 0; }
Solution Explanation
Layman’s Terms
The namespace is like a toolbox. You take out a variable (x) and a tool (function square) from it to use.
Significance for Embedded Developers
In embedded C++, namespaces are often used to group math helpers, driver utilities, or configuration sets without risking name collisions.
Test Cases
Test Results
Input
Expected Output
x=10 Square=100