Home » questions » Using BASIC program, how can we use the existing data for calculation?

Using BASIC program, how can we use the existing data for calculation?

2006-07-29 10:28:08, Category: Programming & Design
For ex. Record is there for different mouldings of unique id number, width and price. We have to calculate the wastage of the moulding. it's actually width multiplied by 8. How to insert the statement into the program. Remember widthis already in the system.

Answers

  1. Boris

    On 2006-07-29 10:37:43


    Read the data into array eg: 10 REM Start count 20 for i in 1 to 10 30 REM Read the data stream and assign it to the variable a subscript i. 40 read a(i) 50 REM End of the loop 60 next a 70 REM Start the loop again 80 for x in 1 to 10 90 REM output the variable a subscript x 100 print a(x) 110 REM End of the loop 120 next x 130 REM Here is the data stream, each component separated by commas. 140 data 1,2,3,4,5,6,7,8,9,10 150 end You can reuse the array a(x) many time. You can also create 2-dimensional array a(x,y) by nesting the for-to-next loops. Sorry if the syntax is not correct, but it's been 15 years since I used BASIC, but it gives you an idea.