This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Character Class Testing & Conversions – 1”.
Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.
1. Which of the following library function is not case-sensitive?
a) toupper()
b) tolower()
c) isdigit()
d) all of the mentioned
View Answer
Explanation: None.
2. The following C expression can be substituted for?
if (isalpha(c) && isdigit(c))
a) if (isalnum(c))
b) if (isalphanum(c))
c) if (isalphanumeric(c))
d) none of the mentioned
View Answer
Explanation: None.
3. Which of the following will return a non-zero value when checked with isspace(c)?
a) blank
b) newline
c) return
d) all of the mentioned
View Answer
Explanation: None.
4. What will be the output of the following C code?
#include <stdio.h>
#include <ctype.h>
int main()
{
char i = 9;
if (isdigit(i))
printf("digit\n");
else
printf("not digit\n");
return 0;
}
a) digit
b) not digit
c) Depends on the compiler
d) None of the mentioned
View Answer
Explanation: None.
5. What will be the output of the following C code?
#include <stdio.h>
#include <ctype.h>
int main()
{
int i = 9;
if (isdigit(i))
printf("digit\n");
else
printf("not digit\n");
return 0;
}
a) digit
b) not digit
c) Depends on the compiler
d) None of the mentioned
View Answer
Explanation: None.
6. What will be the output of the following C code?
#include <stdio.h>
int main()
{
char i = '9';
if (isdigit(i))
printf("digit\n");
else
printf("not digit\n");
return 0;
}
a) digit
b) not digit
c) Depends on the compiler
d) None of the mentioned
View Answer
Explanation: None.
7. What will be the output of the following C code?
#include <stdio.h>
#include <ctype.h>
int main()
{
int i = 0;
if (isspace(i))
printf("space\n");
else
printf("not space\n");
return 0;
}
a) Compile time error
b) space
c) not space
d) None of the mentioned
View Answer
Explanation: The value of variable i is 0 which is the NULL character in ASCII. Hence, the output will be printed as “not space”.
8. What will be the output of the following C code?
#include <stdio.h>
#include <ctype.h>
int main()
{
int i = 32;
if (isspace(i))
printf("space\n");
else
printf("not space\n");
return 0;
}
a) Compile time error
b) space
c) not space
d) None of the mentioned
View Answer
Explanation: The ASCII value of space character is 32. Since the variable i stores 32, the output will be printed as “space”.
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
- Apply for C Internship
- Watch Advanced C Programming Videos
- Apply for Computer Science Internship
- Practice BCA MCQs
- Practice Computer Science MCQs