Saturday, 31 August 2013

Operations with Characters | C Programming Language Material



Operations with Characters:

C language also supports operations with characters and these functions are available in the header file “ctype.h”.
* Note that the value '1' or positive integer will be returned when a condition is true, and value „0? will be returned when condition is false.
Some 'ctype.h' functions are listed below.
Function:
(i) isupper( ) : To test if a character is a upper case letters.
Ex:
isupper('A') ? 1
isupper('a') ? 0
isupper('8') ? 0

(ii) islower( ) : To test if a charcter is a lower case letter.
Ex:
islower('n') ? 1

(iii) isalpha( ) : To test if a character is an alphabet.
Ex:
isalpha('K') ? 1
isalpha('+'?) ? 0

(iv) isalnum( ) : To test if a character is an alphabet or number.
Ex:
isalnum('8') ? 1
isalnum('y') ? 1
isalnum('-') ? 0

(v) isdigit( ) : To test if a character is a number.
Ex:
isdigit('6') ? 1
isdigit('a') ? 0

(vi) isxdigit( ) : To test if a character is a Hexa decimal number (0-9, A-F
and a-f are Hexa decimal digits)
Ex:
isxdigit('9') ? 1
isxdigit('A') ? 1
isxdigit('M') ? 0

(vii) tolower( ) : To convert an alphabet to lower case letter
Ex:
tolower('A') ? a

(viii) toupper( ) : To convert an alphabet to upper case letter
Ex:
toupper('a') ? A.

0 comments:

Post a Comment

 

C Programming Language Interview Questions and Answers Tutorial for beginners. Copyright 2013 All Rights Reserved