This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Character Handling – 2”.
Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.
1. The________function converts an uppercase letter to the corresponding lowercase letter.
a) islower()
b) isupper()
c) toupper()
d) tolower()
View Answer
Explanation: If the argument is a character for which isupper() is true and islower() is true for another set of character, the tolower() function returns the corresponding character;otherwise, the argument is returned unchanged.
2. The toupper() function converts a ______ to the corresponding ______
a) uppercase, lowercase
b) lowercase, uppercase
c) binary, decimal
d) decimal, binary
View Answer
Explanation: The toupper() function is used to convert a lowercase letter to the corresponding uppercase letter.
If the value is a character for which islower() is true and isupper () is true for another set of characters, the toupper() function returns the corresponding character, otherwise, the value is returned unchanged.
3. fgetc, getc, getchar are all declared in ________
a) stdio. h
b) ctype. h
c) assert. h
d) stdarg. h
View Answer
Explanation: The functions getc, fgetc, getchar are all declared in stdio.h header file.
4. isalpha() function is used to detect characters both in uppercase and lowercase.
a) true
b) false
View Answer
Explanation: isalpha() function is used to test for letters in the local alphabet. For the locale, the local alphabet consists of 26 English letters, in each of two cases.
5. What will be the output of the following C code?
int ch= ' '; if(isgraph(ch)) printf("ch = %c can be printed \n",ch); else printf("ch=%c cannot be printed \n",ch);
a) ch = ‘ ‘ can be printed
b) ch = ‘ ‘ cannot be printed
c) compile error
d) run-time error
View Answer
Explanation: void isgraph() function is used to check if the character has graphical representation. Graphical representations character are all those characters that can be printed except for whitespace characters, which is not considered as isgraph characters.
6. The C library function checks whether the passed character is printable.
a) isgraph()
b) isalpha()
c) isprint()
d) ispunct()
View Answer
Explanation: int isprint(int c) function is used to check whether the passed character can be printed.A control character is not a printable character.
7. What will be the output of the following C code?
char ch[ ] = "0xC"; if(isxdigit(ch[ ])) printf("ch = %s is hexadecimal character \n",ch); else printf("ch = %s is not hexadecimal character \n",ch);
a) ch = 0xC is hexadecimal character
b) ch = 0xC is not hexadecimal character
c) compile error
d) run-time error
View Answer
Explanation: The C library function isxdigit checks whether the passed character is a hexadecimal digit.
8. Which among the following option is the full set of character class Hexadecimal digits?
a) { 0 1 2 3 4 5 6 7 8 9 A B C D E F }
b) { 0 1 2 3 4 5 6 7 8 9 a b c d e f }
c) { 0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f }
d) { 0 1 2 3 4 5 6 7 8 9}
View Answer
Explanation: digit or one of the first letters of the alphabet in either case, ‘a’ through ‘f’ and ‘A’ through ‘F’ is contained in the character class Hexadecimal digits.
9. What will be the output of the following C code?
int i = 0; char c; char str[ ] = "Little Star"; while(str[i]) { putchar (toupper(str[i])); i++; }
a) little star
b) lITTLE sTAR
c) LITTLE STAR
d) Little Star
View Answer
Explanation: The C library function toupper converts the lowercase letter to uppercase.
10. What will be the output of the following C code?
int ch = '\t'; if(isprint(ch)) printf("ch = |%c| printable \n", ch); else printf("ch= |%c| not printable \n",ch);
a) ch = |\t| printable
b) ch = |\t| not printable
c) ch = | | printable
d) ch = | | not printable
View Answer
Explanation: isprint() function is used to check whether the passed character is printable. A control character is not a printable 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.
- Get Free Certificate of Merit in C Programming
- Participate in C Programming Certification Contest
- Become a Top Ranker in C Programming
- Take C Programming Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Buy C Books
- Buy Computer Science Books
- Watch Advanced C Programming Videos
- Apply for Computer Science Internship
- Practice BCA MCQs