250+ TOP MCQs on Character Class Testing & Conversions and Answers

C test on “Character Class Testing & Conversions”. One shall practice these test questions to improve their C programming skills needed for various interviews (campus interviews, walkin interviews, company interviews), placements, entrance exams and other competitive exams. These questions can be attempted by anyone focusing on learning C Programming language. They can be a beginner, fresher, engineering graduate or an experienced IT professional. Our C test questions come with detailed explanation of the answers which helps in better understanding of C concepts.

Here is a listing of C test questions on “Character Class Testing & Conversions” along with answers, explanations and/or solutions:

1. Which of the following library function is not case-sensitive?
a) toupper()
b) tolower()
c) isdigit()
d) all of the mentioned
Answer: c
Clarification: 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
Answer: d
Clarification: 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
Answer: d
Clarification: None.

4. What will be the output of the following C code?

  1.     #include 
  2.     #include 
  3.     int main()
  4.     {
  5.         char i = 9;
  6.         if (isdigit(i))
  7.             printf("digitn");
  8.         else
  9.             printf("not digitn");
  10.             return 0;
  11.     }

a) digit
b) not digit
c) Depends on the compiler
d) None of the mentioned
Answer: b
Clarification: None.

5. What will be the output of the following C code?

  1.     #include 
  2.     #include 
  3.     int main()
  4.     {
  5.         int i = 9;
  6.         if (isdigit(i))
  7.             printf("digitn");
  8.         else
  9.             printf("not digitn");
  10.             return 0;
  11.     }

a) digit
b) not digit
c) Depends on the compiler
d) None of the mentioned
Answer: b
Clarification: None.

6. What will be the output of the following C code?

  1.     #include 
  2.     int main()
  3.     {
  4.         char i = '9';
  5.         if (isdigit(i))
  6.             printf("digitn");
  7.         else
  8.             printf("not digitn");
  9.             return 0;
  10.     }

a) digit
b) not digit
c) Depends on the compiler
d) None of the mentioned
Answer: a
Clarification: None.

7. What will be the output of the following C code?

  1.     #include 
  2.     #include 
  3.     int main()
  4.     {
  5.         int i = 0;
  6.         if (isspace(i))
  7.             printf("spacen");
  8.         else
  9.             printf("not spacen");
  10.             return 0;
  11.     }

a) Compile time error
b) space
c) not space
d) None of the mentioned
Answer: c
Clarification: 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?

  1.     #include 
  2.     #include 
  3.     int main()
  4.     {
  5.         int i = 32;
  6.         if (isspace(i))
  7.             printf("spacen");
  8.         else
  9.             printf("not spacen");
  10.             return 0;
  11.     }

a) Compile time error
b) space
c) not space
d) None of the mentioned
Answer: b
Clarification: The ASCII value of space character is 32. Since the variable i stores 32, the output will be printed as “space”.

Leave a Reply

Your email address will not be published. Required fields are marked *