Predefined Characters in C Type Please make sure the program
Predefined Characters in C Type. Please make sure the program compiles thanks :)
// This program reads one character from the keyboard and will // - convert it to uppercase, if it is lowercase // - convert it to lowercase, if it is uppercase // - display a message, if it is not a letter of the alphabet #include #include using namespace std; int main() char c coutc if (isalpha(c)) //check to see if it is a letter of alphabet if (isupper(c))//check to see if it is uppercase coutSolution
#include <iostream>
#include <cctype>
using namespace std;
int main()
{
char c;
cin.get(c); //cin.get() input the character which can be of any type
if(isalpha(c))
{
if(isupper(c))
{
cout<<\"Your character \"<<c<<\" is in uppercase\";
c=tolower(c);
cout<<\"\ Its lowercase is \"<<c<<\".\";
}
else
{
cout<<\"Your character \"<<c<<\" is in lowercase\";
c=toupper(c);
cout<<\"\ Its uppercase is \"<<c<<\".\";
}
}
else if(isdigit(c)) //isdigit() checks if character is a digit
{
cout<<c<<\" is a digit\"<<endl;
}
else if(isspace(c)) //isspace(0 checks if the character is a whitespace)
{
cout<<c<<\"The character you entered is a whitespace\";
}
return 0;
}
output:
4
a
T
