C Questions and Answers – Character Handling – 1

«
»

This set of C MCQs focuses on “Character Handling – 1”.

1. Which header declares several functions useful for testing and mapping characters?
a) assert.h
b) stdio.h
c) ctype.h
d) errno.h
View Answer

Answer: c
Explanation: The header <ctype.h> declares several functions useful for testing and mapping characters.
advertisement

2. The______function tests for any character for which isalpha or isdigit is true.
a) isxdigit()
b) isspace()
c) isalnum()
d) isupper()
View Answer

Answer: c
Explanation: int isalnum(int c)
The isalnum function tests for any character for which isalpha or isdigit is true.

3. What does the following C code do?

advertisement
advertisement
int iscntrl( int c);

a) checks if character is upper case
b) checks if character is lower case
c) tests for any control character
d) no function as such
View Answer

Answer: c
Explanation:
int iscntrl( int c);
The iscntrl function tests for any control character.
advertisement

4. What do the following C function do?

int isgraph(int c);

a) tests for only space character
b) tests for only digit
c) tests for only lower case
d) tests for any printing character
View Answer

Answer: d
Explanation: int isgraph(int c);
The isgraph function tests for any printing character except space.
advertisement

5. The isdigit function tests for any decimal-digit character.
a) true
b) false
View Answer

Answer: a
Explanation: int isdigit(int c);
This function checks whether the passed character is a decimal digit.
advertisement

6. Which function returns true only for the characters defined as lowercase letters?
a) islow()
b) islower()
c) isalpa()
d) isalnum()
View Answer

Answer: b
Explanation: int islower( int c);
The islower function tests for any character that is a lowercase letter.

7. This function checks whether the passed character is white-space.
a) ispunct()
b) isgraph()
c) isspace()
d) isalpha()
View Answer

Answer: c
Explanation: The isspace function tests for any character that is a standard white-space character.

8. The standard white-space characters are the following: space (' '), form feed (' \ f '),
newline (' \n') , horizontal tab (' \tr), and vertlcal tab (' \v') can be tested with function.
a) ispunct()
b) isalpha()
c) isgraph()
d) isspace()
View Answer

Answer: d
Explanation: The isspace function tests for any character that is a standard white-space character.

9. Which function tests for any character that is an uppercase letter.
a) iscntrl()
b) ispunct()
c) isdigit()
d) isupper()
View Answer

Answer: d
Explanation: isupper() returns true only for the characters defined as uppercase letters.

10. The______function tests for any hexadecimal-digit character.
a) iscntrl()
b) ispunct()
c) isgraph()
d) isxdigit()
View Answer

Answer: d
Explanation: int isxdigit( int c) ;
This function tests for any hexadecimal-digit character.

Sanfoundry Global Education & Learning Series – C Programming Language.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

advertisement
advertisement

Leave a Comment

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter