C++ Program to take a value from the user as input any alphabet and check whether it is vowel or consonant. Using user define functions.

Explanation:

  1. Pass-by-Value (isVowelByValue):
    • Function Definition: bool isVowelByValue(char ch)
    • This function takes the character ch as a parameter by value.
    • It converts the character to lowercase using tolower for uniform comparison.
    • It checks if ch is one of the vowels (‘a’, ‘e’, ‘i’, ‘o’, ‘u’).
    • It returns true if the character is a vowel, otherwise false.
  2. Pass-by-Reference (isVowelByReference):
    • Function Definition: void isVowelByReference(char ch, bool &isVowel)
    • This function takes the character ch by value and the result isVowel by reference.
    • It converts the character to lowercase and checks if it is a vowel.
    • The result is stored in the isVowel reference variable.
  3. Main Function (main):
    • The program prompts the user to input an alphabet character.
    • It checks and displays whether the character is a vowel or consonant using both methods.

Example Outputs:

Example 1:

Input:

  • Character: E

Output:

Example 2:

Input:

  • Character: b

Output:

Example 3:

Input:

  • Character: G

Output: