Write a Program in C That Demonstrating The Function Call Stack and Stack Frames Using a Function Square

// Demonstrating the function call stack 
// and stack frames using a function square.
#include <stdio.h>

int square( int ); // prototype for function square

int main()
{
   int a = 10; // value to square (local automatic variable in main)

   printf( "%d squared: %d\n", a, square( a ) ); // display a squared
} // end main

// returns the square of an integer
int square( int x ) // x is a local variable
{
   return x * x; // calculate square and return result
} // end function square

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...