Arrays and Strings in C Exam Notes
Arrays and Strings in C Exam Notes
Arrays and Strings are fundamental concepts in C, used to store and manipulate
data efficiently. Arrays store multiple values of the same data type, while strings are character
Array Declaration: Arrays are declared with a data type, name, and size.
C does not perform automatic bound checking. Accessing elements outside the array
size may lead to undefined behavior. It is the programmer's responsibility to ensure valid
indexing.
3. One-Dimensional Array
Example: int arr[5] = {10, 20, 30, 40, 50}; // Stores 5 elements.
4. Two-Dimensional Array
Example:
Example: char str[6] = "Hello"; // 'Hello' is stored with an implicit null terminator.