Remove consecutive vowels from string | C ++ program for printing sentence without repetitive vowels ; function which returns True or False for occurrence of a vowel ; this compares vowel with character ' c ' ; function to print resultant string ; print 1 st character ; loop to check for each character ; comparison of consecutive characters ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool is_vow ( char c ) { return ( c == ' a ' ) || ( c == ' e ' ) || ( c == ' i ' ) || ( c == ' o ' ) || ( c == ' u ' ) ; } void removeVowels ( string str ) { printf ( " % c " , str [ 0 ] ) ; for ( int i = 1 ; str [ i ] ; i ++ ) if ( ( ! is_vow ( str [ i - 1 ] ) ) || ( ! is_vow ( str [ i ] ) ) ) printf ( " % c " , str [ i ] ) ; } int main ( ) { char str [ ] = " ▁ geeks ▁ for ▁ geeks " ; removeVowels ( str ) ; }