Write a program for analyzing which of severaol diff.vowels ,cont
#
# Since no language was specifiec, here's a solution in the
# gawk dialect of awk.
#
# Familiarity with awk is assumed, so only minimal comments
# are present. I have a version with more comments...
#
BEGIN {
IGNORECASE = 1
}
{ r0 = $0 } # Copy the input record into the variable r0, for efficiency
wc += gsub(/[[:blank:]]+/, "", r0) {} # Destructively count all the white spaces in r0
vc += gsub(/[AEIOU]/, "", r0) {} # Destructively count all the vowels in r0
cc += gsub(/[BCDFGHJKLMNPQRSTVWXYZ]/, "", r0) {} # Destructively count all the consonants in r0
END {
printf("%d vowel%s\n", vc, (vc != 1) ? "s" : "")
printf("%d consonant%s\n", cc, (cc != 1) ? "s" : "")
printf("%d white space%s\n", wc, (wc != 1) ? "s" : "")
}
×