C++ Program to check whether a character is an alphabet or not. Using user define functions.

Explanation:

  1. Pass-by-Value (isAlphabetByValue):
    • Function Definition: bool isAlphabetByValue(char ch)
    • This function takes the character ch as a parameter by value.
    • It checks if ch falls within the range of uppercase (‘A’ to ‘Z’) or lowercase (‘a’ to ‘z’) alphabets.
    • It returns true if ch is an alphabet; otherwise, it returns false.
  2. Pass-by-Reference (isAlphabetByReference):
    • Function Definition: void isAlphabetByReference(char ch, bool &result)
    • This function takes the character ch by value and the result by reference.
    • It performs the same check as isAlphabetByValue but updates the result reference variable.
    • result is set to true if ch is an alphabet, and false otherwise.
  3. Main Function (main):
    • The program prompts the user to input a character.
    • It then checks and displays whether the character is an alphabet using both methods.

Example Outputs:

Example 1:

Input:

  • Character: A

Output:

Example 2:

Input:

  • Character: 9

Output:

Example 3:

Input:

  • Character: *

Output:

 

All Copyrights Reserved 2025 Reserved by T4Tutorials