C Objective Interview Questions – Strings

These C Objective Interview Questions On Strings post providing basic, intermediate and Hard level examples in C Strings. The Practice of these examples makes you good in C programming.


If the two strings are identical, then strcmp() function returns

  1. -1
  2. 1
  3. 0
  4. false
  5. true.

Answer :

Ans : 3

Which of the following function is more appropriate for reading in a multi-word string?

  1. scanf()
  2. gets()
  3. sscanf();
  4. ungets()
  5. None of these.

Answer :

Ans : 2, Can read a string including spaces and it stops reading only when we press return key

What is the return type of strlen() function?

  1. int
  2. unsigned int
  3. size_t
  4. None of above.

Answer :

Ans : 3, size_t represents positive integer value

How is a string typically processed?

  1. On a character by character basis
  2. On a string by string basis
  3. Both A and B
  4. None of the above.

Answer :

Ans : 1, Strings always processed character by character in the application

Which of the following function sets first n characters of a string to a given character?

  1. strinit()
  2. strnset()
  3. striset()
  4. strcset()

Answer :

Ans : 2

Which library function parses the string into tokens?

  1. strtok()
  2. strstr()
  3. toupper()
  4. None.

Answer :

Ans : 1, Used to split the string into tokens(words)

How will you print \n on the screen?

  1. printf(“\n”);
  2. echo “\\n”;
  3. printf(‘\n’);
  4. printf(“\\n”);

Answer :

Ans : 4, ‘\\’ will print ‘\’ on the screen

The if-condition can be replaced with?  [if (isupper(c))]

  1. if (c>=65&&c<=97)
  2. if (c>=97&&c<=122)
  3. if (toupper(c))
  4. None.

Answer :

Ans : 1, ASCII values of A-Z are 65-97

What is the use of ungetc( )

  1. Reads a character
  2. Puts a character
  3. Pushes character back to stream
  4. Nothing.

Answer :

Ans : 3

 C Technical Interview Questions On Structures and Unions

Share this