C Arrays

C Arrays (Complete Tutorial: Beginner → Advanced)
In C language, an array is a collection of multiple values of the same data type stored in contiguous memory locations.
Arrays are fundamental for DSA, system programming, embedded systems, and interviews.
What is an Array?
An array stores multiple values using a single variable name.
Example
marks→ array name5→ number of elements- Index starts from
0
Why Use Arrays?
- Store large data efficiently
- Easy data processing using loops
- Reduces code repetition
- Improves performance
- Basis of DSA (sorting, searching)
Array Declaration
Syntax
Examples
Array Initialization
Method_1: At Declaration
Method_2: Size Automatically Calculated
Method_3: Partial Initialization
Accessing Array Elements
- Index range:
0tosize-1
Array Traversal Using Loop
- Most common operation
Taking User Input in Array
- Used in exams & interviews
Types of Arrays
One-Dimensional Array
Two-Dimensional Array (2D)
Multidimensional Array
Arrays and Functions
Passing Array to Function
- Array is passed by reference
Size of an Array (Important)
- Works only in the same scope
- Not inside function
Arrays and Pointers
- Array name acts as pointer to first element
Common Array Operations
Sum of Elements
Find Maximum
Reverse Array
Limitations of Arrays
- Fixed size
- Cannot grow dynamically
- Stores only same data type
Solved using dynamic memory & structures
Common Mistakes
- Accessing out-of-bounds index
- Forgetting array size
- Using wrong loop condition
- Not passing size to function
Interview Questions (Must Prepare)
What is an array?
Index range of array?
Difference between array and variable?
How to find array size?
How arrays are passed to functions?
Difference between array and pointer?
Real-Life Use Cases
Student marks list
Employee salary data
Sensor readings (embedded)
Game scores
Banking transactions
Summary
- Arrays store multiple values efficiently
- Index starts from 0
- Traversal uses loops
- Passed by reference to functions
- Foundation for DSA, interviews & real projects
