221k views
2 votes
. Which of the following is NOT a valid declaration for a character string?

a) char string1[3] = {“1”, “2”, ‘3’, 4}

b) char string1[12];

c) char string1[] = “this is a string”;

d) char string1[25] = “this is a string”;

User Shobull
by
6.4k points

1 Answer

4 votes

Answer:

a) char string1[3] = {“1”, “2”, ‘3’, 4}

Step-by-step explanation:

From the given options the option a is not a valid declaration.

We are declaring an array of characters string1 also known as c string.Whose size is 3.So it can only hold 3 characters and the third character should be Null(\0) character and we are providing it 4 elements from which 2 of them are strings,one is character and an integer 4.

User Amitsbajaj
by
6.3k points