Unfortunately the assignment specifically wants inertia() to call modulus().

I replaced the modulus and area variables with proper function calls and it works now:

Code:

/* File: lumberfunc.c
This file reads base and height from an input file then uses 3 function to compute the values of the required engineering properties.
Programmer: Sara Stredulinsky Date: 15-Oct-19
*/
#include<stdio.h>
/*Prototypes*/
float area(int base,int height);
float modulus(int base, int height);
float inertia(int base, int height);
int main(void)
{
int base, height;
float csarea, moinertia, secmod;
FILE * fin = fopen("lumberin.txt","r");
FILE * fout = fopen("lumberout.txt","w");
fprintf(fout,"Lumber Size Cross sectional Moment of Section\n Area Inertia Modulus\n--------------------------------------------------------------\n");
while(fscanf(fin,"%d %d\n",&base,&height) != EOF) {
csarea=area(base,height);
secmod=modulus(base,height);
moinertia=inertia(base,height);
fprintf(fout," %d x %d %.2f %.2f %.2f\n",base,height,csarea,moinertia,secmod);
}
fclose(fout);
return 0;
}
float area(int base,int height)
{
float result;
result = base*height;
return result;
}
float modulus(int base,int height)
{
float result;
result = (area(base,height)*height)/6.0;
return result;
}
float inertia(int base, int height)
{
float result;
result = (modulus(base,height)*height)/2.0;
return result;
}

But I still don't get why in the original code modulus() correctly calls area() and uses ((base*height)*height)/6.0 as its calculation, but inertia() which looks like it's built identically to me, calls area() again for ((base*height)*height)/2.0 instead of calling modulus to make (((base*height)*height))/2.0. Can anyone explain what was happening there?