C++ examples for Function:Function Return
Square function used to demonstrate the function call stack and activation records.
#include <iostream> int square(int); int main(int argc, const char *argv[]) { int a = 10; // value to square (local automatic variable in main) std::cout << a << " squared: " << square(a) << std::endl; return 0;//from w ww. jav a 2 s . co m } // returns the square of an integer int square(int x) { // x is a local variable return x * x; }