Find the answer to your Linux question:
Results 1 to 3 of 3
Hello, I am trying to: Write a program that will allow a user to input as many numbers as the user wants ...and then find the sum, average, etc....of those ...
  1. #1
    Just Joined!
    Join Date
    May 2008
    Posts
    4

    reading an unlimited amount of numbers in script

    Hello, I am trying to:
    Write a program that will allow a user to input as many numbers as the user wants ...and then find the sum, average, etc....of those numbers...
    the problem for me is how to write this..?? since it can be an unlimited amount of numbers the user enters, i dont think a simple read num, read num2, read num3....etc...would work...

  2. #2
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    Use a loop and add each number to a running total as it's input. Break out of the loop when no number in entered. Keep as many stats within the loop (number of entries made, etc) as you need to do the final processing.

  3. #3
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    It would also probably help to know the language that you will be using :P

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...