Write a C++ program to input any character and check whether it is the alphabet, digit or special character by using switch statement
Write a C++ program to input any character and check whether it is the alphabet, digit or special character by using the switch statement.
Flowchart of the program to check whether an input is an alphabet, digit or special character – switch statement
C++ Source Code of the program to check whether an input is an alphabet, digit or special character – switch statement
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
#include<iostream> using namespace std; int main() { char num; cout<<"Enter a character:"<<endl; cin>>num; switch(num>='a'&& num<='z'||num>='A'&& num<='Z') { case 1: cout<<"It's alphabet"<<endl; break;
case 0: switch(num>='0' && num<='9') { case 1: cout<<"It's digit"<<endl; break; case 0: cout<<"It's not alphabet and not digit"<<endl; break; } break; } } |
Output
Enter a character:
g
It’s alphabet
SFT (Shamil’s Flow Table )
Are you interested to Read about SFT(Shamil’s Flow Table)?