Javatpoint Logo
Javatpoint Logo

C String Test 2

6) What will be the output of the below program?

  1. 9
  2. 10
  3. 11
  4. Compile error

The correct option is (b).


The function strlen() returns the number of character in the string.

Therefore, strlen("javaTpoint") returns 10

Hence the output of the program is "10".

7) Which of the following statements are correct about string?

  1. The format specifier %s is used to print a string.
  2. The length of the string can be obtained by strlen().
  3. The pointer cannot work on string.
  4. A string is a collection of characters terminated by '\0'.
  1. 1, 4
  2. 1, 2, 3
  3. 1, 2, 4
  4. 2, 3, 4

The correct option is (c).


Clearly the statement 1, 2 and 4 are correct about the string but the statement 3 is incorrect because we can use pointer on strings.

For example: char *p="javaTpoint"

8) For the following statements will arr[2] and ptr[2] fetch the same character?

  1. Yes
  2. No

The correct option is (b).


Yes, for arr[2] and ptr[2] both the statements will prints the same character 'v'.

9) Which of the statements are correct about the below program?

  1. The code converts lower case character to upper case
  2. The code converts upper case character to lower case
  3. The code converts a string to an integer
  4. Compile Time error

The correct option is (a).


The program converts the enter string to upper case string.


10) Determine the wrong file opening mode from the following.

  1. w
  2. a
  3. x
  4. r

The correct option is (c).


File opening mode "x" is incorrect because there is no such mode exists for file opening operation in C language.

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA