Function prototype : Function Prototype « Function « C Tutorial






#include <stdio.h>

int change(int number);                /*Function prototype */

int main(void)
{
  int number = 10;                    
  int result = 0;                     

  result = change(number);
  printf("\nIn main, result = %d\tnumber = %d", result, number);
  return 0;
}

int change(int number)
{
  number = 2 * number;
  printf("\nIn function change, number = %d\n", number);
  return number;
}
In function change, number = 20
     
     In main, result = 20    number = 10








8.3.Function Prototype
8.3.1.Function prototype
8.3.2.Function is defined after main: prototype the function
8.3.3.Function is defined above the function main: it is not necessary to prototype the function