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

Explanation:

  1. Pass-by-Value (checkCaseByValue):
    • Function Definition: void checkCaseByValue(char ch)
    • This function takes the character ch as a parameter by value.
    • It uses isupper to check if ch is an uppercase alphabet, and islower to check if ch is a lowercase alphabet.
    • It prints the result directly, indicating whether ch is an uppercase alphabet, a lowercase alphabet, or not an alphabet.
  2. Pass-by-Reference (checkCaseByReference):
    • Function Definition: void checkCaseByReference(char ch, string &caseType)
    • This function takes the character ch by value and a reference to a string variable caseType.
    • It determines if ch is an uppercase alphabet, a lowercase alphabet, or not an alphabet, and updates the caseType reference variable accordingly.
    • The result is updated through the reference variable.
  3. Main Function (main):
    • The program prompts the user to input a character.
    • It then checks and displays whether the character is an uppercase alphabet, a lowercase alphabet, or not an alphabet using both methods.

Example Outputs:

Example 1:

Input:

  • Character: G

Output:

Example 2:

Input:

  • Character: m

Output:

Example 3:

Input:

  • Character: 5

Output: