Here is the basic structure of a function:return_type function_name (arg_type arg_name, arg_type arg_name, etc...) {
< statements >
return value;
}
(value, value, etc.) indicates values that are 'passed into' the function. They must match both in number and type the list of 'parameters' in the function declaration. When you call a function, the argument variables defined in the parameter list will be initialized with these values.
int leadingDigit (int n) {
while(n>=10)
n/=10;
return n;
}
int a,b;
a = 567;
b = 890;
a = leadingDigit(b);
printf("a is %d and b is %d\n", a, b);
This code will print "a is 8 and b is 890"