Site icon T4Tutorials.com

Write a C program to check whether a character is an alphabet or not by Using the switch statement

Write a C program to check whether a character is an alphabet or not by Using the switch statement.

Flowchart of C program to check whether a character is an alphabet or not

C program to check whether a character is an alphabet or not

#include <iostream> 
using namespace std;
 int main() 
{
    char c;
    cout << "Enter a character?"<<endl;
    cin >> c;
  switch((c >= 'a'&& c <= 'z') || (c >= 'A' && c <= 'Z'))
	 {
	 	case 0:
        cout << c << " is not an Alphabet."<<endl;
        break;
	 	case 1:
        cout << c << " is an Alphabet."<<endl;
        break;
        default:
        	cout<<"Invalid input "<<endl;
    }
}

Output

Enter a character?

r

r is not an Alphabet.

SFT (Shamil’s Flow Table )

Are you interested to Read about SFT(Shamil’s Flow Table)?

 

 

Exit mobile version