// Program to demonstrate the usage of ctype.h - built in functions
#include<ctype.h>
#include<iostream>
using namespace std;
main()
{
char ch;
cout<<" Enter a character ";
cin>>ch;
// 1. Check whether entered characetr is an Alphanumeric Character or not
if(isalnum(ch))
cout<<" Entered character "<<ch <<" is alphanumeric character";
// 2.Check whether entered characetr is an Alphabet or not
if(isalpha(ch))
cout<<"\n" <<ch<< " Character entered and is an alphabet".
// 3. Check whether entered characetr is a Digit or not
if(isdigit(ch))
cout<<" Entered character "<<ch <<" is a digit.";
// 4. Check whether entered characetr is an uppercase letter
if(isupper(ch))
cout<<" Entered character "<<ch <<" is an uppercase letter.";
// 5. Check whether entered characetr is an lowercase letter
if(islower(ch))
cout<<" Entered character "<<ch <<" is an lowercase letter.";
}
#include<ctype.h>
#include<iostream>
using namespace std;
main()
{
char ch;
cout<<" Enter a character ";
cin>>ch;
// 1. Check whether entered characetr is an Alphanumeric Character or not
if(isalnum(ch))
cout<<" Entered character "<<ch <<" is alphanumeric character";
// 2.Check whether entered characetr is an Alphabet or not
if(isalpha(ch))
cout<<"\n" <<ch<< " Character entered and is an alphabet".
// 3. Check whether entered characetr is a Digit or not
if(isdigit(ch))
cout<<" Entered character "<<ch <<" is a digit.";
// 4. Check whether entered characetr is an uppercase letter
if(isupper(ch))
cout<<" Entered character "<<ch <<" is an uppercase letter.";
// 5. Check whether entered characetr is an lowercase letter
if(islower(ch))
cout<<" Entered character "<<ch <<" is an lowercase letter.";
}
No comments:
Post a Comment