Skip to content

Instantly share code, notes, and snippets.

View lornamariak's full-sized avatar
📚
Studying

Lorna Maria lornamariak

📚
Studying
View GitHub Profile
@lornamariak
lornamariak / vowel checker.R
Created October 11, 2017 12:57
COUNTING NUMBER OF VOWELS IN A SENTENCE
x <- readline(prompt = "Enter Sentence: " ) # Ask user to enter word or sentence
#split the sentence into characters and store them as list
sentence = as.list(strsplit(x, "" )[[1]])
vowels = list("a","e","i","o","u") # store vowels as a list
# check for vowels in the sentence and print TRUE for every vowel found
print( vowels %in% sentence )
# print the letters that appear in the vowel list and sentence list
print((intersect(vowels,sentence)))
# print the length of the string in line 8 which is the number of vowels present