Tag Archives: Total Number Of Characters

Python || Count The Total Number Of Characters, Vowels, & UPPERCASE Letters Contained In A Sentence Using A ‘For Loop’

Here is a simple program, which demonstrates more practice using the input/output mechanisms which are available in Python.

This program will prompt the user to enter a sentence, and then display the total number of uppercase letters, vowels and characters contained within that sentence. This program is very similar to an earlier project, this time, utilizing a for loop.


QUICK NOTES:
The highlighted portions are areas of interest.

Notice line 12 contains the for loop declaration. Note that each statement within the for loop block must be uniformly indented, otherwise the code will fail to compile.

Once compiling the above code, you should receive this as your output

Enter a sentence: My Programming Notes Is Awesome.

Total number of UPPERCASE letters: 5
Total number of vowels: 11
Total number of characters: 28

C++ || Count The Total Number Of Characters, Vowels, & UPPERCASE Letters Contained In A Sentence Using A ‘While Loop’

This program will prompt the user to enter a sentence, then upon entering an “exit code,” will display the total number of uppercase letters, vowels and characters contained within that sentence. This program is very similar to an earlier project, this time, utalizing a while loop, the setw and setfill functions.


QUICK NOTES:
The highlighted portions are areas of interest.

In order to use the setfill and setw functions, remember to #include iomanip, as noted on line 2.

Notice line 17 contains the while loop declaration. The loop will continually ask the user to input data, and will not stop doing so until the user enters an exit character, and the defined exit character in this program is a period (“.”). So, the program will not stop asking the user to enter data until they enter a period.

Once compiling the above code, you should receive this as your output

Enter a sentence: My Programming Notes Is Awesome.

Total number of upper case letters:.........5
Total number of vowels:....................11
Total number of characters:................27