370 Programming and Data Structures
Explanation In the above program instead of using macros their corresponding macro expansion is
usedin the program. The first macro expansion&_streams fO] reads string through the keyboard
and the second &_streams [ 1] displaysit.
11.15 THE PREDEFINED MACROS IN c ty p e . h
The header file *c ty p e . h" contains a set of macros that checks character. The Table 11.9 describes all
the macros. These macros take an argument of integer type and return an integer.
Table 11.9 Predefined macros in c ty p e . h .
SR. NO. Macro
Returns true (!0) value if
01
isalpha (d)
d is a letter
02
i supper (d)
disa capital letter
03
islower (d)
d is small letter
04
is d ig it (d)
d is a digit
05 isalnum(d)
d is a letter or digit
06
isxdigit (d)
d is a hexadecimal digit
07
isspace (d)
d is a space
08
ispunct (d)
d is a punctuation symbol
09
i sprint (d)
d is a printable character
10 isgraph(d)
d is printable, but not be a space
11
iscntrl (d)
d is a control character
12 isascii(d)
d is an ASCII code
11.18 Write a program to identify whether the entered character is letter or digit and capital
or small using predefined macros.
# Include <stdio.h>
# Include <comio.h>
# Include <ctype.h>
void mainO
{
char d;
int £;
clrscr () t
printf ( n Enter any character: " ) ;
d=getche();
f=nsalpha(d);
if(fl=Q)
{
printf("n% c is a letter in",d);
f=isupper(d);
if (fi=0)
printfl" Capital case");
else
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.201.217