How to resolve the algorithm Greatest element of a list step by step in the Applesoft BASIC programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Greatest element of a list step by step in the Applesoft BASIC programming language

Table of Contents

Problem Statement

Create a function that returns the maximum value in a provided set of values, where the number of values may not be known until run-time.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Greatest element of a list step by step in the Applesoft BASIC programming language

Source code in the applesoft programming language

 100 REMMAX
 110 R$ = "":E$ = ""
 120 L =  LEN (L$)
 130 IF L = 0 THEN  RETURN
 140 FOR I = 1 TO L
 150     C$ =  MID$ (L$,I,1)
 160     SP = C$ = " "
 170     IF SP THEN  GOSUB 200
 180     E$ = E$ + C$
 190 NEXT I
 200 C$ = ""
 210 IF E$ = "" THEN  RETURN
 220 V =  VAL (E$):V$ = R$
 230 E$ = "":E = V$ = ""
 240 IF E AND V = 0 THEN  RETURN
 250 R$ =  STR$ (V)
 260 IF E THEN  RETURN
 270 R =  VAL (V$)
 280 IF R < V THEN  RETURN
 290 R$ = V$: RETURN

L$ = "1 2 3 4 20 6 11 3 9 7"
GOSUB 100MAX
PRINT R$

  

You may also check:How to resolve the algorithm Knapsack problem/Continuous step by step in the R programming language
You may also check:How to resolve the algorithm Sierpinski carpet step by step in the JavaScript programming language
You may also check:How to resolve the algorithm Sort using a custom comparator step by step in the Standard ML programming language
You may also check:How to resolve the algorithm Knight's tour step by step in the CoffeeScript programming language
You may also check:How to resolve the algorithm Sorting algorithms/Stooge sort step by step in the REXX programming language