Count how many vowels and consonants occur in a string: Difference between revisions
Count how many vowels and consonants occur in a string (view source)
Revision as of 16:00, 26 July 2021
, 2 years ago→{{header|Ring}}
Thundergnat (talk | contribs) m (→{{header|Ring}}: more verbiage) |
|||
Line 98:
=={{header|Ring}}==
<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)
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
done...
</pre>
|