219k views
3 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 JSous
by
4.7k points

1 Answer

1 vote

Answer:

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

Step-by-step explanation:

In the declaration we have a string of size 3 from which 1 block is reserved for null character and we are declaring a string of size 4 and out them two are of type string and 1 is a character and 1 is an integer.

All the other three declarations are correct they will run on the IDE.

So we can say that the answer to this question is option a.

User Stonemonk
by
4.5k points