Check special character in C++ by R4R Team

Special characters:
All Character except the English alphabet and numbers are the special characters.

Example-
! # $ % ^ & * ( ) etc.

How we identify?
-We use the ASCII value concept to identify each and every character of the keyword.

program-

#include
int main()
{
char ch;
cout<<"Enter any character"< scanf("%c",&ch);
if((ch>='A' && ch<='Z') | (ch>='a' && ch<='z') | (ch>='0' && ch<='9'))
{
}
else
{
cout<<"It is a special character";
}
return 0;
}


output-

Enter any character
A
It is not a special character

Enter any character
3
It is not a special character

Enter any character
$
It is a special character

-In this program, we take a input of the any character,and check whether it is special character or not.
-We check that character is alphabet,numbers or not.
-If input character is not the alphabet or not the number then it will execute the else part which will implies as special character were input.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!