Program to accept a Strings which contains all the Vowels | C ++ implementation to check that a string contains all vowels ; Function to to check that a string contains all vowels ; Hash Array of size 5 such that the index 0 , 1 , 2 , 3 and 4 represent the vowels a , e , i , o and u ; Loop the string to mark the vowels which are present ; Loop to check if there is any vowel which is not present in the string ; Function to to check that a string contains all vowels ; Driver Code
#include <iostream> NEW_LINE using namespace std ; int checkIfAllVowels ( string str ) { int hash [ 5 ] = { 0 } ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str [ i ] == ' A ' str [ i ] == ' a ' ) hash [ 0 ] = 1 ; else if ( str [ i ] == ' E ' str [ i ] == ' e ' ) hash [ 1 ] = 1 ; else if ( str [ i ] == ' I ' str [ i ] == ' i ' ) hash [ 2 ] = 1 ; else if ( str [ i ] == ' O ' str [ i ] == ' o ' ) hash [ 3 ] = 1 ; else if ( str [ i ] == ' U ' str [ i ] == ' u ' ) hash [ 4 ] = 1 ; } for ( int i = 0 ; i < 5 ; i ++ ) { if ( hash [ i ] == 0 ) { return 1 ; } } return 0 ; } int checkIfAllVowelsArePresent ( string str ) { if ( checkIfAllVowels ( str ) ) cout << " Not ▁ Accepted STRNEWLINE " ; else cout << " Accepted STRNEWLINE " ; } int main ( ) { string str = " aeioubc " ; checkIfAllVowelsArePresent ( str ) ; return 0 ; }