Which data type is used to store a sequence of characters in C?

Which data type is used to store a sequence of characters in C?

a) int
b) char
c) float
d) array of char

Answer:

d) array of char

Explanation:

In C, a sequence of characters is stored in an array of char data type. Strings in C are represented as arrays of characters, with the last element being the null character (\0) that indicates the end of the string. For example, char str[10] = "Hello"; is an array of characters representing the string “Hello”.

Understanding how to use character arrays to handle strings is crucial for text processing and string manipulation in C programming.

Reference links:

https://www.rameshfadatare.com/learn-c-programming/

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top