Program to accept Strings starting with a Vowel Last Updated : 13 Sep, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report Given string str consisting of alphabets, the task is to check whether the given string is starting with a Vowel or Not. Examples: Input: str = "Animal" Output: Accepted Input: str = "GeeksforGeeks" Output: Not Accepted Approach: Find the first character of the stringCheck if the first character of the string is a vowel or notIf yes, print AcceptedElse print Not Accepted Below is the implementation of the above approach: CPP // C++ program to accept String // starting with Vowel #include <iostream> using namespace std; // Function to check if first character is vowel int checkIfStartsWithVowels(string str) { if (!(str[0] == 'A' || str[0] == 'a' || str[0] == 'E' || str[0] == 'e' || str[0] == 'I' || str[0] == 'i' || str[0] == 'O' || str[0] == 'o' || str[0] == 'U' || str[0] == 'u')) return 1; else return 0; } // Function to check void check(string str) { if (checkIfStartsWithVowels(str)) cout << "Not Accepted\n"; else cout << "Accepted\n"; } // Driver function int main() { string str = "animal"; check(str); str = "zebra"; check(str); return 0; } Java // Java program to accept String // starting with Vowel class GFG { // Function to check if first character is vowel static int checkIfStartsWithVowels(char []str) { if (!(str[0] == 'A' || str[0] == 'a' || str[0] == 'E' || str[0] == 'e' || str[0] == 'I' || str[0] == 'i' || str[0] == 'O' || str[0] == 'o' || str[0] == 'U' || str[0] == 'u')) return 1; else return 0; } // Function to check static void check(String str) { if (checkIfStartsWithVowels(str.toCharArray()) == 1) System.out.print("Not Accepted\n"); else System.out.print("Accepted\n"); } // Driver code public static void main(String[] args) { String str = "animal"; check(str); str = "zebra"; check(str); } } // This code is contributed by PrinciRaj1992 Python3 # Python3 program to accept String # starting with Vowel # Function to check if first character is vowel def checkIfStartsWithVowels(string) : if (not(string[0] == 'A' or string[0] == 'a' or string[0] == 'E' or string[0] == 'e' or string[0] == 'I' or string[0] == 'i' or string[0] == 'O' or string[0] == 'o' or string[0] == 'U' or string[0] == 'u')) : return 1; else : return 0; # Function to check def check(string) : if (checkIfStartsWithVowels(string)) : print("Not Accepted"); else : print("Accepted"); # Driver function if __name__ == "__main__" : string = "animal"; check(string); string = "zebra"; check(string); # This code is contributed by AnkitRai01 C# // C# program to accept String // starting with Vowel using System; class GFG { // Function to check if first character is vowel static int checkIfStartsWithVowels(char []str) { if (!(str[0] == 'A' || str[0] == 'a' || str[0] == 'E' || str[0] == 'e' || str[0] == 'I' || str[0] == 'i' || str[0] == 'O' || str[0] == 'o' || str[0] == 'U' || str[0] == 'u')) return 1; else return 0; } // Function to check static void check(String str) { if (checkIfStartsWithVowels(str.ToCharArray()) == 1) Console.Write("Not Accepted\n"); else Console.Write("Accepted\n"); } // Driver code public static void Main(String[] args) { String str = "animal"; check(str); str = "zebra"; check(str); } } // This code is contributed by PrinciRaj1992 JavaScript <script> // Javascript program to accept String // starting with Vowel // Function to check if first character is vowel function checkIfStartsWithVowels(str) { if (!(str[0] == 'A' || str[0] == 'a' || str[0] == 'E' || str[0] == 'e' || str[0] == 'I' || str[0] == 'i' || str[0] == 'O' || str[0] == 'o' || str[0] == 'U' || str[0] == 'u')) return 1; else return 0; } // Function to check function check(str) { if (checkIfStartsWithVowels(str)) document.write( "Not Accepted<br>"); else document.write("Accepted<br>"); } var str = "animal"; check(str); str = "zebra"; check(str); // This code is contributed by SoumikMondal </script> Output: Accepted Not Accepted Time complexity: O(1) as it is performing constant operations Auxiliary space: O(1) Comment More infoAdvertise with us Next Article Program to accept Strings starting with a Vowel C code_r Follow Improve Article Tags : DSA Similar Reads Program to accept String starting with Capital letter Given a string str consisting of alphabets, the task is to check whether the given string is starting with a Capital Letter or Not.Examples: Input: str = "GeeksforGeeks"Output: Accepted Input: str = "geeksforgeeks"Output: Not Accepted Approach: Find the ASCII value of the first character of the stri 3 min read Check if a string can be split into two substrings with equal number of vowels Given a string S, the task is to check if the string can be split into two substrings such that the number of vowels in both of them are equal. If found to be true, then print "Yes". Otherwise, print "No". Examples: Input: S = "geeks"Output: YesExplanation: Splitting the strings into substrings "ge" 15+ min read Program to duplicate Vowels in String Given a string "str", the task is to duplicate vowels in this string. Examples: Input: str = "geeks"Output: geeeeks Input: str = "java"Output: jaavaa Approach: Iterate the string using a loop. Check if the character is a vowel and duplicate it. Return then print the resultant string. Below is the im 5 min read Sort a string without altering the position of vowels Given a string S of size N, the task is to sort the string without changing the position of vowels. Examples: Input: S = "geeksforgeeks"Output: feeggkokreessExplanation:The consonants present in the string are gksfrgks. Sorting the consonants modifies their sequence to fggkkrss.Now, update the strin 5 min read Substrings starting with vowel and ending with consonants and vice versa Given a string s, count special substrings in it. A Substring of S is said to be special if either of the following properties is satisfied. It starts with a vowel and ends with a consonant.It starts with a consonant and ends with a vowel. Examples: Input : S = "aba" Output : 2 Substrings of S are : 15+ min read Like