Hi I've made a program but for some reason I am getting this error that I can't even begin to decipher because it won't point me to where the error has been made. I am using the PV=ZnRT formula.
Here is the error:
1>C:\Users\user\Documents\Visual Studio 2008\Projects\lab24jess\Debug\lab24jess.exe : fatal error LNK1120: 1 unresolved externals
Here is my program:
#include <stdio.h>
#include <math.h>
void User_input (double *temp, double *mass, double *volume, double *Mmass, double *Pc, double *Tc);
void Cal_Z (double *T, double *m, double *v, double *Mm, double *Cp, double *Tc);
double CalculateNewZ (double Pr, double Tr);
void Print_Ans (double answer);
void main ()
{
double temperature, kg, vol, molar, Pcrit, Tcrit, Z;
User_input (&temperature, &kg, &vol, &molar, &Pcrit, &Tcrit);
Cal_Z (&temperature, &kg, &vol, &molar, &Pcrit, &Tcrit);
flushall ();
getchar ();
}
void User_input (double *temp, double *mass, double *volume, double *Mmass, double Pc, double *Tc)
{
printf ("Please enter the temperature in degrees Celsius: ");
scanf ("%lf", temp);
printf ("Please enter the mass in kg: ");
scanf ("%lf", mass);
printf ("Please enter the volume in M63: ");
scanf ("%lf", volume);
printf ("Please enter the molar mass in kg/mo: ");
scanf ("%lf", Mmass);
printf ("Please enter the critical pressure in kpa: ");
scanf ("%lf", Pc);
printf ("Please enter the critical temperature in kelvin: ");
scanf ("%lf", Tc);
}
void Cal_Z (double *T, double *m, double *v, double *Mm, double *Cp, double *Tc)
{
double pressure;
double Z=1;
double R=8.31451;
double znew;
double Pr=0;
double Tr=0;
double count;
pressure = Z*(*m/ *Mm)*(R*(273.15+*T))/ *v;
Pr = pressure /(*Cp);
Tr = 286.15/(*Tc);
znew = CalculateNewZ (Pr, Tr);
printf ("/n Z Pressure Pr Tr Znew");
do
{
printf ("/n%0.6lf %0.6lf %0.6lf %0.6lf %0.6lf", Z, pressure, Pr, Tr, znew);
pressure = Z*(*m/ *Mm)*(R*(273.15+*T))/ *v;
Pr = pressure /(*Cp);
Tr = 286.15/(*Tc);
count = Z - znew;
Z = znew;
znew = CalculateNewZ (Pr, Tr);
}
while (count != 0);
pressure = pressure - 92.03;
Print_Ans (pressure);
}
double CalculateNewZ(double Pr, double Tr)
{
/****************************************************************
* Function which calculates Z using the Redlich-Kwong EOS
* Refer Perry's Chemical Engineer's Handbook - 7th edition 1999
* Chapter 4 - Page 4-20 and 4-21 - (Equations 4-223 and 4-224 are
* where the coefficients 0.42748 and 0.08664 were obtained).
* You may copy this subroutine into your programs so long
* as this header is preserved in full.
* Copyright (C) 2003 - J.J.Jacq
******************************************************************/
double a = .42748 * Pr/ pow(Tr,2.5);
double b = .08664 * Pr / Tr;
double R1 = a - b * (1.0 + b);
double R2 = a * b;
double fz = 1.0;
double z = 1.0;
double dfz;
while ( fz > 0.0001)
{
fz = pow(z,3) - pow(z,2) + R1*z - R2;
dfz = 3*(z*z) - 2*z + R1;
z = z - fz/dfz;
fz = abs(fz);
}
return z;
}
void Print_Ans (double answer)
{
printf ("/n/nThe pressure is %0.6lf kPag.", answer);
}