C Programming Questions and Answers – Character Class Testing & Conversions – 1

«
»

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.

advertisement

1. Which of the following library function is not case-sensitive?
a) toupper()
b) tolower()
c) isdigit()
d) all of the mentioned
View Answer

Answer: c
Explanation: None.

2. The following C expression can be substituted for?

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!
advertisement
advertisement
 if (isalpha(c) && isdigit(c))

a) if (isalnum(c))
b) if (isalphanum(c))
c) if (isalphanumeric(c))
d) none of the mentioned
View Answer

Answer: d
Explanation: None.
advertisement

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

Answer: d
Explanation: None.

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

advertisement
  1.     #include <stdio.h>
  2.     #include <ctype.h>
  3.     int main()
  4.     {
  5.         char i = 9;
  6.         if (isdigit(i))
  7.             printf("digit\n");
  8.         else
  9.             printf("not digit\n");
  10.             return 0;
  11.     }

a) digit
b) not digit
c) Depends on the compiler
d) None of the mentioned
View Answer

Answer: b
Explanation: None.
advertisement

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

  1.     #include <stdio.h>
  2.     #include <ctype.h>
  3.     int main()
  4.     {
  5.         int i = 9;
  6.         if (isdigit(i))
  7.             printf("digit\n");
  8.         else
  9.             printf("not digit\n");
  10.             return 0;
  11.     }

a) digit
b) not digit
c) Depends on the compiler
d) None of the mentioned
View Answer

Answer: b
Explanation: None.

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

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

a) digit
b) not digit
c) Depends on the compiler
d) None of the mentioned
View Answer

Answer: a
Explanation: None.

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

  1.     #include <stdio.h>
  2.     #include <ctype.h>
  3.     int main()
  4.     {
  5.         int i = 0;
  6.         if (isspace(i))
  7.             printf("space\n");
  8.         else
  9.             printf("not space\n");
  10.             return 0;
  11.     }

a) Compile time error
b) space
c) not space
d) None of the mentioned
View Answer

Answer: c
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?

  1.     #include <stdio.h>
  2.     #include <ctype.h>
  3.     int main()
  4.     {
  5.         int i = 32;
  6.         if (isspace(i))
  7.             printf("space\n");
  8.         else
  9.             printf("not space\n");
  10.             return 0;
  11.     }

a) Compile time error
b) space
c) not space
d) None of the mentioned
View Answer

Answer: b
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.

advertisement
advertisement

Leave a Comment

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 & technical discussions at Telegram SanfoundryClasses.