It's me again. :?:
This is the question: Write a computer program that computes the temperature of a gas that is originally at P=5 atm, =V30 Liters, T=273 K. Solve the problem using one dimensional array only. Assume number of array elements is unknown (use the end of file function).
And we have 10 errors:
for
int P[N], T[N], V[N];
3X error C2057: expected constant expression
3X error C2466: cannot allocate an array of constant size 0
error C2133: 'P/T/V' : unknown size
for
((Pinit*Vinit)/Tinit)=((P[i]*V[i])/T[i]);
error C2106: '=' : left operand must be l-value
#include <iostream>
#include <fstream>
using namespace std;
ifstream infile("TEMPER.dat");
ofstream outfile("RESULT.dat");
int main()
{
int N;
N=infile.eof();
cout<<"There are "<<N<<" elements in the input file"<<endl;
int i=0;
double Pinit=5, Vinit=30, Tinit=273;
double P[N], T[N], V[N];
for (i=0; !infile.eof(); i++)
{ infile>>P[i]>>V[i];
((Pinit*Vinit)/Tinit)=((P[i]*V[i])/T[i]);
for (i=0; i<N; i--)
{cout<<i;
outfile<<i;};
cout<<"Case\t"<<"P(atm)\t"<<"V(l)\t"<<"T(K)"<<endl
<<"----"<<"------"<<"-----"<<"----"<<endl
<<"\t"<<P[i]<<"\t"<<V[i]<<"\t"<<T[i]<<"\t"<<endl;
outfile<<"Case\t"<<"P(atm)\t"<<"V(l)\t"<<"T(K)"<<endl
<<"----"<<"------"<<"-----"<<"----"<<endl
<<"\t"<<P[i]<<"\t"<<V[i]<<"\t"<<T[i]<<"\t"<<endl;
}
return 0;
}