How to resolve the algorithm Letter frequency step by step in the BBC BASIC programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Letter frequency step by step in the BBC BASIC programming language

Table of Contents

Problem Statement

Open a text file and count the occurrences of each letter. Some of these programs count all characters (including punctuation), but some only count letters A to Z.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Letter frequency step by step in the BBC BASIC programming language

Source code in the bbc programming language

      DIM cnt%(255)
      
      file% = OPENIN("C:\unixdict.txt")
      IF file%=0 ERROR 100, "Could not open file"
      
      REPEAT
        A$ = GET$#file%
        L% = LEN(A$)
        IF L% THEN
          FOR I% = 1 TO L%
            cnt%(ASCMID$(A$,I%)) += 1
          NEXT
        ENDIF
      UNTIL EOF#file%
      CLOSE #file%
      
      FOR c% = &41 TO &5A
        PRINT CHR$(c%)CHR$(c%+32) ": " cnt%(c%)+cnt%(c%+32)
      NEXT


  

You may also check:How to resolve the algorithm Bitmap/PPM conversion through a pipe step by step in the Julia programming language
You may also check:How to resolve the algorithm Paraffins step by step in the Phix programming language
You may also check:How to resolve the algorithm Sorting algorithms/Comb sort step by step in the Kotlin programming language
You may also check:How to resolve the algorithm Diversity prediction theorem step by step in the BASIC programming language
You may also check:How to resolve the algorithm Roots of unity step by step in the Pascal programming language