clear;clc;
q = input('enter any quote in english:','s');%accepting any quote as a string
in = input('which letter do you want to count:','s');%asking which letter to count
tex = find(q == in);%finding the letter in the quote
count_tex = length(tex);%counting the number of instances
fprintf('The number of %s are: %d.\n',in,count_tex);%output the count
v = ['a','e','i','o','u'];%vowels
count_vow = 0;
%counting each vowel
for i = 1:5
count_vow = count_vow+length(find(q == v(i)));
end
fprintf('The number of vowels are: %d.\n',count_vow);%output of vowel count
Comments
Leave a comment