checking if the character is numeric or alphabet

Hi guys, Im making a program that enter a character and the output identifies if its numerical, alphabet or special character..

Sorry for my English, I hope you guys understand.

Can you check this code guys?... Thanks for advance...

#include <iostream>
using namespace std;

main()
{
char x;
cout << "Enter a character> ";
cin >> x;

if (x > 0) {
cout << x << " is a number.\n ";
}
if (x == "a") {
cout << x << " is a letter.\n";
}
if (x == "e") {
cout << x << " is a letter.\n";
}
if (x == "i") {
cout << x << " is a letter.\n";
}
if (x == "o") {
cout << x << " is a letter.\n";
}
if (x == "u") {
cout << x << " is a letter.\n";
}
else {
cout << x << " is a special character.\n";
}

return 0;
}
Last edited on
You can use functions from cctype http://www.cplusplus.com/reference/clibrary/cctype/
Topic archived. No new replies allowed.