Example Program
  • Developed at Dartmouth College (1964) with much of design coming from FORTRAN.
  • Two characteristics that made it popular:
    1. Easy for beginners to learn, especially those not science oriented
    2. Its smaller dialects could be implemented on computers with very small memory
  • First widely used language that was used through terminals connected to a remote computer.
  1. REM BASIC Example Program
  2. REM Input: An integer, listlen, where listlen is less
  3. REM than 100, followed by listlen-integer values
  4. REM Output: The number of input values that are greater
  5. REM than the average of all input values
  6. DIM intlist(99)
  7. result = 0
  8. sum = 0
  9. INPUT listlen
  10. IF listlen > 0 AND listlen < 100 THEN
  11. REM Read input into an array and compute the sum
  12. FOR counter = 1 TO listlen
  13. INPUT intlist(counter)
  14. sum = sum + intlist(counter)
  15. NEXT counter
  16. REM Compute the average
  17. average = sum / listlen
  18. REM Count the number of input values that are > average
  19. FOR counter = 1 TO listlen
  20. IF intlist(counter) > average
  21. THEN result = result + 1
  22. NEXT counter
  23. REM Print the result
  24. PRINT "The number of values that are > average is:";
  25. result
  26. ELSE
  27. PRINT "Error—input list length is not legal"
  28. END IF
  29. END