C Programming Quiz : Strings and Characters

C Programming Quiz: Get String and Character Multiple Choice Questions (MCQ Quiz) with answers.

C Programming Quiz : Strings and Characters


1. What is a String in C Language?
  • A) String is an array of Characters with null character as the last element of array.
  • B) String is an array of Characters with null character as the first element of array.
  • C) String is an array of Integers with 0 as the last element of array.
  • D) None of these

Answer is A)
Description:
String is an array of Characters with null character as the last element of array.

2. What is the Format specifier used to print a String or Character array in C Printf or Scanf function?
  • A) %w
  • B) %C
  • C) %c
  • D) %s

Answer is D)
Description:
%s is the Format specifier used to print a String or Character array in C Printf or Scanf function. the format specifier %c only use for one character.
For example:
In this below code, the printf statement will print whole string. "Hello..!"

3. Choose a correct statement about C String.
  • A) ary has no Null character at the end
  • B) String size is not mentioned.
  • C) Character array, ary is a string.
  • D) String can not contain special characters.

Answer is C)
Description:
It is a simple way of creating a C String. You can also define it like the below. \0 is mandatory in this version.

4. What is the output of C Program?
  • A) C
  • B) Coding Taggers
  • C) Coding
  • D) Compile Error

Answer is B)
Description:
%s prints the while character array in one go.

5. What is the maximum length of a C String?
  • A) 32 characters
  • B) 64 characters
  • C) 256 characters
  • D) None of these.

Answer is D)
Description:
Maximum size of a C String is dependent on implemented PC memory. C does not restrict C array size or String Length.

6. How do you accept a Multi Word Input in C Language?
  • A) SCANF
  • B) GETC
  • C) GETS
  • D) FINDS

Answer is C)
Description:
Yes. gets(str) fills the array str with the input given by the user.

7. Choose a correct C Statement about Strings.
  • A) GETS is capable of accepting a multi word string from console or command prompt.
  • B) PUTS is capable of printing a multi word string.
  • C) PRINTF is capable of printing a multi word string.
  • D) All of these.

Answer is D)
Description:
Read all the options carefully.

8. What is the output of C Program with strings?

Input: CTQuiz
  • A) CT
  • B) CTQuiz
  • C) Compiler error
  • D) None of these

Answer is B)
Description:
It always overwrites the next memory locations of the array. It is your responsibility to check bounds. Scanf automatically adds a '\0' at the end of entered string.

9. A character constant is enclosed by?
  • A) Double Quotes
  • B) Right Single Quotes
  • C) Left Single Quotes
  • D) None of the above.

Answer is B)
Description:
char ary[] = {'a','b','\0'}.
char bry[] = {`a`,`b`,`c`}; is wrong as it uses Left Single Quotes.

10. A C string elements are always stored in?
  • A) Sequential memory locations
  • B) Alternate memory locations
  • C) Random memory locations
  • D) None of the above

Answer is A)
Description:
A C string elements are always stored in Sequential memory locations.


Submit your Quiz Question
Submit your quiz question to us, We will feature your quiz question in our blog with your credits.