/* * funcint2.c */ #include int getint(void); // function prototype: takes nothing, returns int float intaverage(int, int, int); // prototype: takes 3 int's, returns a float int main(void) // header for function main: takes nothing, returns int { int aa, bb, cc; // declare 3 ints float avrg; // declare float puts("This program calculates the average of three integers.\n"); aa=getint(); // call funtion getint, assign to aa bb=getint(); // call funtion getin, assign to bb cc=getint(); // call funtion getin, assign to cc avrg=(float)(aa+bb+cc)/3; // add aa, bb, and cc, // divide result by 3.0 // Assign to float avrg printf("The average of %d, %d, and %d is %f.\n", aa,bb,cc,avrg); // output result. return 0; // return 0 to calling program } float intaverage( int xx, int yy, int zz) // function header { return (float)(xx+yy+zz)/3; // add xx to yy to zz // cast resutl to a float // divide by 3 // return result to calling function } int getint(void) { int ii; // declare int printf("Type an integer and press Enter: "); // prompt for input scanf("%d", &ii); // read from stdin // interpret as a digit // assign to memory location of ii return (ii); // return value of ii to calling function }