445,820 Members | 1,154 Online
Need help? Post your question and get tips & solutions from a community of 445,820 IT Pros & Developers. It's quick & easy.

# lowest number

 P: n/a I am having problems with this question: Write a C++ while statement that will input numbers from a file until the end of file is reached. Output the lowest number in the file. Ok, I do understand the logic, I believe the following for loop solves it from keyboard input. But how do you point to any given value from a file. You can't assign anything to a variable. Little lost on this one. Thanks, Kelsey Jul 19 '05 #1
5 Replies

 P: n/a "Randi" wrote... I am having problems with this question: Write a C++ while statement that will input numbers from a file until the end of file is reached. Output the lowest number in the file. There is no question here. It looks much more like an assignment. Have you tried asking your teacher about it? Ok, I do understand the logic, I believe the following for loop solves it from keyboard input. Which "following for loop" are you talking about? But how do you point to any given value from a file. You can't assign anything to a variable. Little lost on this one. To input something from a file you need to open a file. Read about ifstream class in your textbook. Victor Jul 19 '05 #2

 P: n/a "Randi" wrote... I am having problems with this question: Write a C++ while statement that will input numbers from a file until the end of file is reached. Output the lowest number in the file. There is no question here. It looks much more like an assignment. Have you tried asking your teacher about it? Ok, I do understand the logic, I believe the following for loop solves it from keyboard input. Which "following for loop" are you talking about? But how do you point to any given value from a file. You can't assign anything to a variable. Little lost on this one. To input something from a file you need to open a file. Read about ifstream class in your textbook. Victor Jul 19 '05 #3

 P: n/a On Wed, 12 Nov 2003 02:50:59 GMT, Randi wrote: I am having problems with this question: Write a C++ while statement that will input numbers from a file until the end of file is reached. Output the lowest number in the file. Ok, I do understand the logic, I believe the following for loop solves it from keyboard input. But how do you point to any given value from a file. You didn't write anything here. Start with a function : int min_number(istream& is) { // istream contains integer>0 numbers up to the end int i(1000); // all numbers suppose to be smaller then 1000 while(is) { // you can read anything if "is" is good int j; is >> j; // attempt to read the number if(is) // if you read the number "is" state should be good if(j> operator. Thanks, Kelsey -- grzegorz Jul 19 '05 #4

 P: n/a Whoa there, I am not a kid trying to get an answer for an assignment. I am a 38 year old student taking my required C++ class for my IT degree. I am also a member of Phi Theta Cappa with a 3.8 GPA, trying to study for an exam tomorrow. These are practice problems to help us study. Here is my code for the for loop. How would you make this work taking input from a file. Thanks, Kelsey "Victor Bazarov" wrote in message news:bohsb.128304\$9E1.638773@attbi_s52... "Randi" wrote... I am having problems with this question: Write a C++ while statement that will input numbers from a file until the end of file is reached. Output the lowest number in the file. There is no question here. It looks much more like an assignment. Have you tried asking your teacher about it? Ok, I do understand the logic, I believe the following for loop solves it from keyboard input. Which "following for loop" are you talking about? But how do you point to any given value from a file. You can't assign anything to a variable. Little lost on this one. To input something from a file you need to open a file. Read about ifstream class in your textbook. Victor Jul 19 '05 #5