Need helpCounting every single letter from a string word by word

Write your question here.
Although I have been coding for some time. I have decided to make the jump that has scared me for a while. This was getting out of my "coding comfort zone" as I was good at Python programming language but was ready for something harder. I love C++ so far and I am currently solving problems but I am getting stuck.

I am working on a algorithm puzzle that requires me to get every single word from a sentence and see if it is a pangram. Please I emphasize DO NOT give me the answer that would defeat the purpose of me learning but I need some help on how to get C++ to go through each letter of the sentence to see if it matches A-Z then add that to a counter.
So your problem is taking a sentence and verifying whether it is a pangram? Like "The quick brown fox jumps over the lazy dog"?

If this is what you want, then you can do as follows:
1. you declare an array of counters with 26 cells (one for each letter of the alphabet)
2. you scan the sentence and, for every letter, you increment its counter
3. at the end you scan the array and conclude that the sentence is a pangram if and only if every element of the array is at least 1.

Note. Given a letter, you can map it to a number in a very easy and standard way:

number = letter - 'a'

Note 2. It could be a good idea to preprocess every letter with a tolower to avoid problems with capital letters.

Let me know how it goes!
Last edited on
Topic archived. No new replies allowed.