Hey guys:
Can anyone please help me. I am having problems with this program and nned help understanding this. here is the code and the problem. Thanks.
=========Mr. President============
Use a text editor such as Notepad to create a text file that contains several integers. The first integer in the file should be the number of (double) numbers that follow. Name this file assign6.txt.
Write a program that reads from the file the number of numbers to process (the first number in the file) and then reads the remaining numbers into a double array. Assume that there will be no more than 100 numbers to process. After reading all of the numbers into the array, close the file. Then have your program display all of the numbers in the array, five numbers per line, with a precision of 2 and using 10 columns for each number. Don't forget to provide appropriate messages before displaying any numbers. After displaying the numbers in the array, then display the largest and the smallest numbers in the array. Your program should use functions for determining the largest and smallest.
==========================================================
# include <iostream>
# include < iomanip>
# include <fstream>
using namespace std;
const int dMAX = 100;
int getData (int numbers [], int size, int range);
void printData (const int numbers[], int size, int lineSize);
int main (void)
{
int size;
int nums [dMAX];
size= getData (nums, dMAX);
printData (nums, size, 10);
return 0;
}
int getData (int data [], int size, int range)
{
char aChar;
int dataIn;
int loader = 0;
while (loader < size && (fsData >> dataIn))
if dataIn >= 0 && dataIn <= range)
data [loader+=] = dataIn;
else
cout << 'Data point " << dataIn << "invalid. Ignored. \n";
return loader;
void printData (const int data [], int size, int lineSize)
cout << setw (3) << list [i];
if (numPrinted < 4)
numPrinted++;
else
{
cout << endl;
numPrinted = 0;
}
cout << endl << endl;
return;
}
<< moderator edit: added [code][/code] tags >>