#include <stdio.h>
/* global definition of a function prototype */
/* known to all functions */
int add_two (int, int); /* Method 2a */
int main ()
{
int doubled; /* the result of a number doubled */
int sum; /* the sum of two numbers */
int val; /* just a number to work with */
val = 100;
/* local declaration of a function prototype */
/* known only to calls to it in the main function */
int double_it (int); /* Method 2b */
sum = add_two (val, val*5);
doubled = double_it (val);
printf("sum = %i and doubled = %i\n", sum
, doubled
);
return(0);
}
// **************************************************
// Function: add_two
//
// Description: Adds to numbers together and returns
// their sum.
//
// Parameters: num1 - first integer to sum
// num2 - second integer to sum
//
// Returns: result - sum of num1 and num2
//
// ***************************************************
int add_two (int num1, int num2)
{
int result; /* sum of the two number */
result = num1 + num2;
return (result);
}
// **************************************************
// Function: double_it
//
// Description: Adds to numbers together and returns
// their sum.
//
// Parameters: num - number to double
//
// Returns: answer - the value of num doubled
//
// ****************************************************
int double_it (int num)
{
int answer; /* num being doubled */
answer = num + num;
return (answer);
}