Monday, July 27, 2009

C++ program help PLEASE!!!!!????

I am supposed to write a program that asks the user for a file name. The program should read the contents of the file and display the following data:


the lowest number, the highest, the total of the numbers, and the average of the numbers.


My program will compile but it never reads the numbers from the file. It just gives me random numbers. My teacher wants us to use functions for everything, but I don't get what to do in the function readNumbers. My teacher completely left us on our own to do this. He just walked out of class so can anyone please help me with this?

C++ program help PLEASE!!!!!????
void readNumbers(ifstream %26amp;refVar,int [] a, int s){


ifstream inputFile;


inputFile.open("numbers.txt");





// write code to read numbers from the file here





inputFile.close();


}





For starters, this function doesn't read any numbers.


The code would be something like





for ( int i = 0; i %26lt; s; ++i){


inputFile %26gt;%26gt; a[i];


}





The function must be called with parameters as well (stream to the file, pointer to the array, and array size); in your main, it's not.
Reply:http://www.thescripts.com/forum/forum129...


ask ur question on here its a c/c++ fourm

song downloads

No comments:

Post a Comment