Can array subscripts have negative value in C?
C Programming Language > Array in C Language > Single Dimensional Array
1303
Answer:
No. Array subscripts should not have a negative value. Always, it should be positive.
No, array subscripts cannot have negative values in C. Array subscripts are used to access individual elements of an array by specifying their position or index. In C, array indexing starts from zero, so the first element of an array has an index of 0, the second element has an index of 1, and so on.
Attempting to use a negative value as an array subscript would result in undefined behavior. It can lead to memory access errors, data corruption, or program crashes. It is important to ensure that array subscripts are within the valid range of the array size to access elements correctly and avoid unintended consequences.
This Particular section is dedicated to Question & Answer only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.
Join Our telegram group to ask Questions
Click below button to join our groups.