I've revised calc_abv function proposed by laseright and hodor by shifting the array of coefficients to main(). In this manner I can use the same code for the inverse function, calc abw for abv. Just different coefficients.

It looks like it should work but I can't find the error at the end of main(): "error: expected expression before ')' token".

A search tells me it's likely a naming/type problem or syntax error. By the message, I'd assume it's in main() but I'm not seeing it. What am I missing??

Thanks.

Code:#include <stdio.h> #include <stdlib.h> #include <math.h> #define NUM_MIXTURE_PERCENTAGES 101 #define MOLAR_MASS_WATER 18.0153 /*Grams per mol*/ #define MOLAR_MASS_ETHANOL 46.0684 /*Grams per mol*/ /*Function Prototype*/ double convert(double abw_to_abv[], double abw); /*converts alcohol by weight %mass-%mass to %vol-%vol*/ double calc_abw(double mol_mass_e, double mol_mass_w, double mol_frac1, double mol_frac2);/*converts from mol% to %mass, mol fractions of x or mol fractions of y*/ int main() { int index = 0; double x1 = 0; /*x1 is liquid molar fraction of ethanol*/ double x2 = 1-x1; /*x2 is liquid molar fraction of water*/ double boiler_abv = 0; double abw = 0; double abw_to_abv[9] = /*Array of E Croissants coefficients for conversion of alcohol by mass to alcohol by volume*/ { -0.000039705486746795932, 1.2709666849144778, -0.40926819348115739, 2.0463351302912738, -7.8964816507513707, 15.009692673927390, -15.765836469736477, 8.8142267038252680, -2.0695760421183493 }; for (int index = 0; index < NUM_MIXTURE_PERCENTAGES; index++) { abw = calc_abw(MOLAR_MASS_ETHANOL, MOLAR_MASS_WATER, x1, x2); boiler_abv = convert(abw_to_abv, abw); printf("\nfraction \tabw \tboiler_abv\n"); printf("%1.2f %1.2f %1.2f\n", x1, abw, boiler_abv); x1 += 0.01; x2 += 0.01; } return(); } /********************************FUNCTIONS******************************/ double calc_abw(double mm_e, double mm_w, double mf1, double mf2) { double result = 0; result = mf1/(mf1 + mm_w/mm_e * mf2); return (result); } /**********************************************************************/ /*Calculates alcohol by volume from alcohol by weight. Source: On the Conversion of Ethanol by Edwin Croissant 02-14-2016 */ /*Result between 0 and 1. Valid only for input between 0 and 1 and valid only at 20 degrees C*/ /*Initial polynomial y = a + b*x + c*x^2 + d*x^3 + f*x^4 + g*x^5 + h*x^6 + i*x^7 + j*x^8*/ double convert(double abw_to_abv[], double abw) { double abv = 0; abv = abw_to_abv[0]; double abw_mult = abw; for (size_t i = 1; i < sizeof(abw_to_abv) / sizeof(abw_to_abv[0]); ++i) { abv = abv + abw_to_abv[i] * abw_mult; abw_mult *= abw; } return abv; }