AIQ4 - delete x fout.close system"minmax.out"...

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("minmax.out"); return 0; } void readdat(int&n,float*x) { ifstream fin("minmax.in"); int i(0); fin>>n; for(i=0;i<n;i++) { fin>>x[i]; } fin.close(); } void minmax(int n,float*x,float&min,float&max) { int i; min=x[i]; max=x[i]; for(i=1;i<n;i++) { if(min>x[i]) min=x[i]; if(max<x[i]) max=x[i]; } }...
View Full Document

This note was uploaded on 02/21/2010 for the course ENGM 2282 taught by Professor Phillips during the Winter '10 term at Dalhousie.

Ask a homework question - tutors are online