![]() |
|
#1
|
|||
|
|||
Greatest and smallest integersHello, i was asked to write a program that asks the user to enter a list of integers. The program should continue asking the user for integers until the user enters -99 which means finish the list. Then after the user is finished the program should display only the greatest and smallest integers.
So far so good, that part is not so hard, but he asked to made the program by using two functions (plus the main function). One function should keep track of the largest and smallest integers and the other one should just display the results. I ve tried many ways the whole morning but with no success.. I don't know how to elavorate the program to make it work properly.. Can anyone give me some tips on how to arrange the program? Like, in what function to call first, or in which function should I set the loop to keep asking for integers? Please, any help will be much appreciated! thanks |
|||
|
#2
|
|||
|
|||
Re: Greatest and smallest integersAssume first integer as largest and smallest, then iterate over the list of integer.
|
|
#3
|
|||
|
|||
Re: Greatest and smallest integersmmmm look what I ve done so far... the problem is that at the end when displaying the results.. the program gives me the greatest number only (as the smallest & greatest) Please, any ideas what am i doing wrong??
CPP / C++ / C Code:
|
|
#4
|
|||
|
|||
Re: Greatest and smallest integersQuote:
CPP / C++ / C Code:
|
|
#5
|
|||
|
|||
Re: Greatest and smallest integersIt doesn't compile if i take it out.. I think there is other problem though.. the program is not really doing what i want it to do...
|
|
#6
|
|||
|
|||
Re: Greatest and smallest integersThe program is setting the last integer entered by the user as the smallest and greatest value...
|
|
#7
|
|||
|
|||
Re: Greatest and smallest integersthis felt a little better.. I re-arranged the whole program, still doesnt work right....
Any ideas or tips? please? CPP / C++ / C Code:
|
|
#8
|
|||
|
|||
Re: Greatest and smallest integersLook that the result depends on the first number you give.
For example: if you give the integer 10 at first and 8 next, your program will assign 8 only to greatest, when should also assign it to the least. CPP / C++ / C Code:
|
|
#9
|
||||
|
||||
Re: Greatest and smallest integersQuote:
Quote:
Quote:
__________________
During the election they said Obama could only be elected when pigs fly. Well, we currently have an epidemic of Swine Flu. Coincidence? |
Recent GIDBlog
Toyota - 2009 May Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Equation solver | RazoR | C Programming Language | 3 | 18-May-2008 10:24 |
| Two-Tier data dissemination code installation problem | nidhibansal1984 | Computer Software Forum - Linux | 6 | 16-Sep-2007 11:13 |
| BOOKEEPING program, HELP!! | yabud | C Programming Language | 10 | 17-Nov-2006 04:48 |
| Help with a complex program | lordfuoco | C++ Forum | 5 | 24-Jun-2006 07:03 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The