------------------------------------------------------------------------------
MC logo
Functional Average
[^] Code Examples
------------------------------------------------------------------------------
<<Calculator Example average2.c Functional Average II>>
#include <stdio.h>
double av(int n1, int n2, int n3)
{
        double sum;

        sum = n1 + n2 + n3;
        return sum / 3.0;
}
int main(void)
{
        int n1, n2, n3;

        printf("Enter: ");
        scanf("%d %d %d", &n1, &n2, &n3);

        printf("Mean %d %d %d is %f\n",
                n1, n2, n3, av(n1, n2, n3));

        return 0;
}

Main is just the function that the O/S calls to get the program started.

Plain C does not have have classes; functions exist at the top level. The are called without a class or object name. C++ supports the same syntax; it has both top-level functions, and Java-like methods.

Parameters are passed by value.
But we will show some variations later.

Reading: pp. 125-144 exc. arrays
<<Calculator Example Functional Average II>>