I created a simple program to check whether the letter that a user has inputed is either uppercase or lowercase and then convert the lowercase to uppercase and the uppercase to lowercase using the std::isupper()
and std::islower()
funtion. upon running the code I get the character converion in number form instead of the expected uppercase/lowercase equivalent. Why is that?
#include <iostream>
int main()
{
char letter {};
std::cout << "Enter a letter:";
std::cin >> letter;
if (std::isupper(letter))
{
std::cout << "You entered an uppercase letter"
"\n"
"the lowercase equivalent is:"
<< std::tolower(letter);
}
if (std::islower(letter))
{
std::cout << "You entered a lowercase letter"
"\n"
"the uppercase equivalent is:"
<< std::toupper(letter);
}
return 0;
}
Here is an example of an output below:
Enter a letter:F
You entered an uppercase letter.
The lowercase equivalent is:102
Enter a letter:f
You entered a lowercase letter.
The uppercase equivalent is:70