CHARACTER HANDLING LIBRARY FUNCTIONS

Character handling Functions Includes functions to perform useful tests and manipulations on character data. Each function receives a character (an int) or EOF as an argument. These library functions exists in the header <ctype.h>. Commonly used Character handling functions are:

1. int isdigit( int )
2. int isalpha( int )
3. int isalnum( int)
4. int islower( int )
5. int isupper( int )
6. int tolower( int )
7. int toupper( int )

Program to Convert lower case character to upper case and vice versa.

#include<ctype.h>
#include<stdio.h>
int main()
{
char ch; clrscr();
printf("Enter a Character : "); scanf("%c", &ch);
if(islower(ch))
ch = toupper(ch);
else
ch = tolower(ch);
printf("\n\tCharacter After Reversing case is : %c", ch);
getch(); return 0;
}

 Program to Check whether the character read is digit or an alphabet.

#include<ctype.h>
#include<stdio.h>
int main()
{
char ch; clrscr();
printf("Enter a Character: "); scanf("%c",&ch);
if(isdigit(ch))
printf("\n\tCharacter %c is a Digit", ch);
if(isalpha(ch))
printf("\n\tCharacter %c is a Alphabet", ch);
getch(); return 0;
}
CHARACTER HANDLING LIBRARY FUNCTIONS CHARACTER HANDLING LIBRARY FUNCTIONS Reviewed by Unknown on 04:50 Rating: 5

No comments:

Powered by Blogger.