How to resolve the algorithm Letter frequency step by step in the Ring programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Letter frequency step by step in the Ring 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 Ring programming language
Source code in the ring programming language
textData = read("C:\Ring\ReadMe.txt")
ln =len(textData)
charCount = list(255)
totCount = 0
for i =1 to ln
char = ascii(substr(textData,i,1))
charCount[char] = charCount[char] + 1
if char > 31 totCount = totCount + 1 ok
next
for i = 32 to 255
if charCount[i] > 0 see char(i) + " = " + charCount[i] + " " + (charCount[i]/totCount)*100 + " %" + nl ok
next
You may also check:How to resolve the algorithm String length step by step in the SETL programming language
You may also check:How to resolve the algorithm Abundant, deficient and perfect number classifications step by step in the Phix programming language
You may also check:How to resolve the algorithm FASTA format step by step in the Go programming language
You may also check:How to resolve the algorithm Happy numbers step by step in the Dart programming language
You may also check:How to resolve the algorithm Find the last Sunday of each month step by step in the JavaScript programming language