Accountancy, asked by meghanagarla, 1 month ago

which of the following statements are correct?
1.A string is a collection of characters terminated by '\0'.
2.The format specifier %s is used to print a string.
3.The length of the string can be obtained by strlen().
4. The pointer CANNOT work on string.
o ​

Answers

Answered by alaiisah
1

Answer:

the statement number four is the correct one

Answered by SteffiPaul
0

The statements which are true are as follows:

(1) A string is a collection of characters terminated by '\0'.

(2) The format specifier '%s' is used to print a string.

(3) The length of the string can be obtained by 'strlen()'.

∴ Statements (1), (2) and (3) are correct.

Explanation:

  • String is the set of characters that ends with a null character '\0'.
  • The string in C language is one-dimensional array of character which is terminated by null character.
  • Strings are always enclosed within double quotes
  • The '%s' format specifier is implemented by representing strings.
  • It is used in the printf() function for printing a string stored in the character array variable.
  • strlen function is built-in string function in C programming, it is useful to find the string of the length.
  • Syntax of the strlen function is: C strlen function will count the number of characters in a string until it reaches the null value (0) and returns that integer value as output.

#SPJ2

Similar questions