Re: Using get() to read multiple keyboard input
- Posted by "Thomas Parslow (PatRat)" <patrat at INAME.COM> Aug 23, 2000
- 532 views
------------100721A1637825C > I'm curious to know whether it's possible to use get() in this situation: > 1 ask user to type some numbers, each separated by a space > 2 enter the whole set of numbers > 3 read the numbers -- can you use get() here? > 4 compute their average > 5 display the average to screen > The point of my query is that get() has to be issued separately for each > number - which is OK if you know beforehand how many numbers the user will > enter. If the choice is left up to the user (so it may vary at each program > run), is it possible to write code that can "sense" how many numbers have > been entered? This value could then be used to call get() the required > number of times. > Thank you > Alex Caracatsanis It is not possible to use get() to read in a list of numbers seperated by spaces, you could allow the user to enter the numbers like a sequence "{1,2,3,4,5}". I have attached an example program that allows the user to enter any amount of numbers seperated by spaces (or commas) then prints the avarge. Thomas Parslow (PatRat) ICQ #:26359483 Rat Software http://www.ratsoft.freeserve.co.uk/ Please leave quoted text in place when replying ------------100721A1637825C