First you need to prototype your function. That means you have to create a declaration so that the compiler knows about the function. Now you are using find_max() in main() before the compiler knows about find_max(). Prototyping goes like this:
Code:
void find_max (int a, int b);
Your function needs to have a type. In your situation it would be like this:
Code:
void find_max (int a, int b)
{
...
}
Also note that I've used the new style C here. The style you are using is quite old, or are you using an old compiler?
A function can return a value. The purpose of letting a function return a value is that in the calling function the return value can be used. Like this:
Code:
#include <stdio.h>
int find_max (int a, int b);
int main ()
{
int max, a = 1, b = 2;
max = find_max (a, b);
printf ("Max is %d\n", max);
return 0;
}
int find_max (int a, int b)
{
if (a > b)
return a;
else
return b;
}
Here the function find_max() returns a value of type int and it is stored in a variable of type int.