![]() |
| ||
| a little help I've written the program out but I'm not sure on how I can get the largest and smallest # to display.. can anyone help? thanks. Write a program with a loop that lets the user enter a series of integers. The user should enter -99 to signal the end of the series. After all the numbers have been entered, the program should display the largest and smallest numbers entered. #include <iostream> using namespace std; int main() { int number = 0; cout << "This program will let you enter number after\n"; cout << "number. Enter 99 when you want to quit the "; cout << "program.\n"; while (number !=99) cin >> number; cout << "Done\n"; return 0; } |
| ||
| Re: a little help I think this would work: #include <iostream> |
| ||
| Re: a little help Little help please: cout << "loop.\n"; does this play any role or its just an output -> "n" I didn’t understand this part too: min = max = number; Why did we have to equal the min and max to number...? Which is 0? Are max and min are reserved word for C++. |
| ||
| Re: a little help >cout << "loop.\n"; does this play any role or its just an output -> "n" I assume you mean \n. It's an escape character that tells cout to print a newline. >Why did we have to equal the min and max to number...? Which is 0? min and max denote the smallest and largest value encountered, respectively. Because at this point the only value encountered was number, both min and max must be that value. >Are max and min are reserved word for C++. Yes and no. The rules are a bit tricky, but in this case there's no problem. |
| All times are GMT -4. The time now is 10:10 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC