AIQ4 - delete x; fout.close();...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
void readdat(int&,float*); void minmax(int,float*,float&,float&); #include <iostream> #include <fstream> const int N = 100; using namespace std; int main(void) { ofstream fout("minmax.out"); float x[N]; int n; float max; float min; readdat(n,x); minmax(n,x,min,max); fout << "The array has " << n << " elements\n"; fout << "The maximum value in the array is " << max << endl; fout << "The minimum value in the array is " << min << endl;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: delete x; fout.close(); system(&quot;minmax.out&quot;); return 0; } void readdat(int&amp;n,float*x) { ifstream fin(&quot;;); int i(0); fin&gt;&gt;n; for(i=0;i&lt;n;i++) { fin&gt;&gt;x[i]; } fin.close(); } void minmax(int n,float*x,float&amp;min,float&amp;max) { int i; min=x[i]; max=x[i]; for(i=1;i&lt;n;i++) { if(min&gt;x[i]) min=x[i]; if(max&lt;x[i]) max=x[i]; } }...
View Full Document

Ask a homework question - tutors are online