1. isalpha – returns true if the argument is an alphabet, returns false otherwise.
Syntax: void isalpha(char)
Example 1 : Checking if the user has entered an alphabet or not.
#include
void main()
{
char c;
printf(“\nEnter an alphabet : “);
scanf(“%c”,&c);
if(isalpha(c)) // check if the entered value is a alphabet
printf(“\nThis is an alphabet”);
else
printf(“\nThis is either a digit or a symbol”);
}
2. isalpha – returns true if the argument is a digit, returns false otherwise.
Syntax : void isdigit(char)
Example 2 : Checking if the user has entered a digit or not.
#include
void main()
{
char c;
printf(“\nEnter a digit : “);
scanf(“%c”,&c);
if(isdigit(c)) // check if the entered value is a digit
{
printf(“\nThis is a digit”);
else
printf(“\nNot a digit”);
}
Syntax : void isalnum(char)
Example 3: Checking if the user has entered a digit or not.
#include
void main()
{
char c;
printf(“\nEnter a digit or an alphabet : “);
scanf(“%c”,&c);
if(isalnum(c))
printf(“\nThis is either an alphabet or a digit”);
else
printf(“\nYou’ve entered a symbol”);
}
Syntax: void isupper (char)
Example 4: Checking if the user has entered a capital case alphabet or not.
#include
void main()
{
char c;
printf(“\nEnter an alphabet : “);
scanf(“%c”,&c);
If(isalpha(c))
{
if(isupper(c))
printf(“\nThis is a capital letter”);
else
printf(“\nThis is a small letter”);
}
else
printf(“\nThis is not an alphabet”);
Syntax: void islower(char)
Example 5 : Checking if the user has entered a small case alphabet or not.
#include
void main()
{
char c;
printf(“\nEnter an alphabet : “);
scanf(“%c”,&c);
if(isalpha(c))
{
if(islower(c))
printf(“\nThis is a small letter”);
else
printf(“\nThis is a capital letter”);
}
else
printf(“\nThis is not an alphabet”);
}
Syntax : void isspace(char)
Example 2 : Checking if the user has entered a space or not.
#include
void main()
{
char c;
printf(“\nEnter any character : “);
scanf(“%c”,&c);
if(isspace(c))
printf(“\nSpace not allowed”);
else
printf(“\nYou entered %c”,c);
}
0 comments:
Post a Comment