#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
auto square = [](int x) { return x * x; };
cout << "Square=" << square(n);
return 0;
}
Explanation & Logic Summary:
[](int x) { return x * x; } is assigned to the variable squaremain(), keeping the logic local and concisex * x remains within the valid bounds of a 32-bit int👉 In simple words:
This is a small, inline function created exactly where it is needed, avoiding unnecessary global functions.
Firmware Relevance & Real-World Context:
In firmware and embedded C++:
This problem reinforces safe arithmetic, modern C++ usage, and embedded-friendly coding practices.
Input
5
Expected Output
Square=25