Count how many vowels and consonants occur in a string: Difference between revisions

m (→‎{{header|Ring}}: more verbiage)
Line 98:
 
=={{header|Ring}}==
 
{{incorrect|Ring|[, ], \, _, and ` are not consonants. Even without those caveats, the count of consonants is incorrect.}}
<lang ring>
load "stdlib.ring"
Line 107:
 
for n = 1 to len(str)
strc = str[n]
if isvowel(str[n]) = 1
vowel += 1
ok
else not isvowel(str[n]) and ascii(str[n]) > 64 and ascii(str[n]) < 123
if isconsonant(strc)
cons += 1
ok
Line 118 ⟶ 120:
see "In string occur " + cons + " consonants" + nl
see "done..." + nl
 
func isconsonant(c)
bool1 = not isvowel(c)
bool2 = (ascii(c) > 64 and ascii(c) < 91)
else notbool3 = isvowel(str[n]) and ascii(str[n]c) > 6496 and ascii(str[n]c) < 123)
if bool1 and (bool2 or bool3)
return 1
else
return 0
ok
</lang>
{{out}}
Line 124 ⟶ 136:
Input string = "Forever Ring Programming Language"
In string occur 11 vowels
In string occur 2419 consonants
done...
</pre>
2,468

edits