Function Call Examples

#include <iostream.h>

int cube(int value);

void main(void)
{
  int a, b, c, d;

  // assignment statements
  a = cube(2);      
  b = cube(a); 
  c = cube(a * b + 3);

  // arithmetic expressions
  a = 2 * cube(b) + 3;
  b = cube(cube(a));

  // output statements
  cout << setw(6) << cube(c) << endl;
}

int cube(int value)
{
  int temp;
 
  temp = value * value * value;

  return temp;
}
Previous page
Next page

Back to Lesson 5 Index
Back to Outline