C-ctype.h Library Function
All inbuilt function
which are declared in ctype.h header file are there and they are
1.
isalnum()
2.
isalpha()
3.
isdigit()
4.
islower()
5.
isuper()
Now will define the
ctype function.
Fig: ctype.h function |
1.
isalnum()
check whether character
is alphanumeric.
Program:
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
void main()
{
int ch;
printf(“Input string”);
if(isalum(ch))
printf(“the int”);
else
printf(“the alphabet”);
getch();
}
Output:
Input string
a
the alphabet
2.isalpha()
Check whether character
is alphabetic.
Program:
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
void main()
{
char dwivedi;
printf(“Input string”);
scanf(“%c”, &dwivedi)
if(isalph(dwivedi))
printf(“the character
is alphabet”);
else
printf(“the alphabet is
not a character ”);
getch();
}
Output:
Input string
Dwivedi
The character is
alphhbet
3.isdigit()
Check whether character
is digit.
Program:
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
void main()
{
char ch;
printf(“Input value”);
scanf(“%c”, &ch)
if(isdigit(ch))
printf(“the alphabet is digit”);
else
printf(“the alphabet is
not a digit”);
getch();
}
Output:
Input value
Ram
The alphabet is not a
digit
4.islower()
Convert to lowercase.
Program:
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
void main()
{
char ch;
printf(“Input value”);
scanf(“%c”, &ch)
if(islower(ch))
printf(“the alphabet is lower case”);
else
printf(“the char is not
in lower case”);
getch();
}
Output:
Input value
Ram
The alphabet is lower
case
5.isupper()
Covert into upper case.
Program:
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
void main()
{
char ch;
printf(“Input value”);
scanf(“%c”, &ch)
if(isupper(ch))
printf(“the char is upper case”);
else
printf(“the char is not
uppercase”);
getch();
}
Output:
Input value
RAM
The char is upper case
No comments:
Post a Comment