C++ Program to count Vowels in a string using Pointer Last Updated : 27 Sep, 2019 Comments Improve Suggest changes Like Article Like Report Pre-requisite: Pointers in C++ Given a string of lowercase english alphabets. The task is to count number of vowels present in a string using pointers Examples: Input : str = "geeks" Output : 2 Input : str = "geeksforgeeks" Output : 5 Approach: Initialize the string using a character array. Create a character pointer and initialize it with the first element in array of character (string). Create a counter to count vowels. Iterate the loop till character pointer find '\0' null character, and as soon as null character encounter, stop the loop. Check whether any vowel is present or not while iterating the pointer, if vowel found increment the count. Print the count. Below is the implementation of the above approach: CPP // CPP program to print count of // vowels using pointers #include <iostream> using namespace std; int vowelCount(char *sptr) { // Create a counter int count = 0; // Iterate the loop until null character encounter while ((*sptr) != '\0') { // Check whether character pointer finds any vowels if (*sptr == 'a' || *sptr == 'e' || *sptr == 'i' || *sptr == 'o' || *sptr == 'u') { // If vowel found increment the count count++; } // Increment the pointer to next location // of address sptr++; } return count; } // Driver Code int main() { // Initialize the string char str[] = "geeksforgeeks"; // Display the count cout << "Vowels in above string: " << vowelCount(str); return 0; } Output: Vowels in above string: 5 Comment More infoAdvertise with us Next Article C++ Program to count Vowels in a string using Pointer B bilal-hungund Follow Improve Article Tags : Technical Scripter C++ GATE cpp-string cpp-pointer +1 More Practice Tags : CPP Similar Reads Count the pairs of vowels in the given string Given a string str consisting of lowercase English alphabets, the task is to count the number of adjacent pairs of vowels.Examples: Input: str = "abaebio" Output: 2 (a, e) and (i, o) are the only valid pairs.Input: str = "aeoui" Output: 4 Approach: Starting from the first character of the string to 5 min read stringstream in C++ and its Applications A stringstream associates a string object with a stream allowing you to read from the string as if it were a stream (like cin). To use stringstream, we need to include sstream header file. The stringstream class is extremely useful in parsing input. Basic methods are:clear()- To clear the stream.str 3 min read Count substrings that contain all vowels | SET 2 Given a string str containing lowercase alphabets, the task is to count the sub-strings that contain all the vowels at-least one time and there are no consonants (non-vowel characters) present in the sub-strings.Examples: Input: str = "aeoibsddaaeiouudb" Output: 4 Explanation: The 4 distinct substri 12 min read C++ Program to Count the Number of Spaces in a File Here, we will see how to count number of spaces in a given file. First, we will read the contents of the file word by word, keep one counter variable 'count', and set it to zero while declaring. Increment 'count' each time you read a single word from the file. Example: Input: Geeks For Geeks Output: 2 min read C++ Program To Find If A Character Is Vowel Or Consonant In English Alphabet, vowels are 'a', 'e', 'i', 'o', and 'u'. The rest of the remaining characters (like 'b', 'c', 'd', 'f' ....) are consonants. In this article, we will learn to write a C++ program to check whether a character is Vowel or Consonant. C++ Program to Check Whether a Character is a Vow 2 min read Like