In this video, we learn how to solve a classic beginner coding problem: How to count the number of Vowels and Consonants in a given string.
This is an excellent exercise for mastering if-else conditions, switch statements, and loop iterations. We will also cover how to handle case sensitivity (e.g., 'A' vs 'a') and how to ignore non-alphabetic characters like numbers and special symbols.
Example:
Input: "Hello World"
Output: Vowels: 3 (e, o, o), Consonants: 7 (H, l, l, W, r, l, d)
🔥 In this tutorial, you will learn: ✅ The Logic: iterating through a string character by character. ✅ Conditionals: Checking if a character is a Vowel (a, e, i, o, u). ✅ The "Else" Trap: Why you can't just use else for consonants (you must check if it's a letter first!). ✅ Handling Case: Converting to lowercase before checking. ✅ Code Implementation in [Python/Java/C++].
📝 The Core Logic:
Initialize vowels = 0 and consonants = 0.
Loop through the string str.
Convert the current character to lowercase to handle 'A' and 'a' easily.
If char is in ['a', 'e', 'i', 'o', 'u'] → increment vowels.
Else If char is between 'a' and 'z' → increment consonants.
Hashtags: #Programming #CodingInterview #StringManipulation #Python #Java #CPP #VowelsAndConsonants #BeginnerCoding #DataStructures #Algorithms
On this page of the site you can watch the video online Count Vowels and Consonants in a String || Python Placement Coding with a duration of hours minute second in good quality, which was uploaded by the user Blessy Lectures 23 January 2026, share the link with friends and acquaintances, this video has already been watched 30 times on youtube and it was liked by 5 viewers. Enjoy your viewing!