summaryrefslogtreecommitdiff
path: root/reference/C/EXAMPLES/function.c
blob: dbd0b3546c6735e1afa19e7cd3d86d9e7419253e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/************************************************************************
 *
 * Purpose: Program to demonstrate functions.
 * Author:  M J Leslie.
 * Date:    28-Feb-94
 *
 ************************************************************************/

int add( int, int); 			/* Function declaration 	*/

main()
{
  int i=1;
  printf("i starts out life as %d.", i);

  i = add(1, 1);			/* Function call       		*/

  printf(" And becomes %d after function is executed.\n", i);
}

/************************************************************************/

int add( int a, int b) 			/* Function definition 		*/
{
  int c;
  c = a + b;
  return c;
}