C Questions and Answers – Character Handling – 1

This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Character Handling – 1”.

Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.

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.

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.
advertisement
advertisement

3. What does the following C code do?

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.
Note: Join free Sanfoundry classes at Telegram or Youtube

4. What do the following C function do?

advertisement
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.

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.

To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). 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!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.