|
25 Years of Programming
An open source source for C, C++, OWL, BASIC, MDB, XLS, DOT, and more... |
Home Projects Up Sitemap Search Blog Forum+Chat About Us Privacy Terms of Use Feedback FAQ Images Services Payments Humor Music |
SUM.BAS adds a list of numbers. You can enter the numbers using the numeric keypad. After each one, press Enter (easier to hit accurately than the "+" key), and the program automatically prints out the sum. To start fresh, press Enter twice.
If you want to sum a list of numbers NOW, I have an online calculator that will do it (and other statistical calculations) using JavaScript.
10 REM SUM.BAS 11 'Copyright (C)1982 Steven Whitney. 12 'Published under GNU GPL (General Public License) Version 3, with ABSOLUTELY NO WARRANTY. 13 'Initially published by http://25yearsofprogramming.com. 18 'TRIVIAL BUT USEFUL PROGRAM THAT ALLOWS QUICKLY SUMMING A COLUMN OF NUMBERS 20 'USING THE NUMERIC KEYPAD, BY INTERPRETING THE KEYPAD ENTER KEY AS A + SIGN. 30 'IF YOU ENTER 0 OR A BLANK LINE, IT PRINTS THE TOTAL AND STARTS FRESH. 40 'SO IF THE NUMBER ACTUALLY IS 0, DON'T ENTER IT! 50 DIM A(300) 60 INPUT A(I) 70 B=B+A(I) 80 PRINT,B 90 I=I+1 100 IF A(I-1)<>0 THEN 60 110 PRINT STRING$(20,"="):CLEAR:GOTO 50 120 END
|
|
|
|
|
|
Copyright ©2010 Steven Whitney. Last modified Thu 10/21/2010 02:08:03 -0700. |
||