TITLE
Introduction to Arrays in C Programming
WHAT IS AN ARRAY?
 An array is a collection of variables of the same data type.
 Stores data in a single variable rather than using separate variables for each value.
 Helps in organizing data in an ordered format.
WHY USE ARRAYS?
Arrays help to store multiple values together, saving time and space.
Useful for managing large sets of similar data, like scores, marks, or names.
 Makes programs more organized and efficient.
ARRAY SYNTAX
 Syntax to declare an array : data type array name [array size];
 Example: int numbers[5]; int: data type of the array elements, Numbers: name of the array, [5]: size of the
array (can store 5 integers).
HOW ARRAY ELEMENTS ARE STORED ?
Array elements are stored in contiguous (continuous) memory locations.
Each element can be accessed using an index:
Index starts at 0.
Example:
numbers[0] is the 1st
element.
 Numbers[1] is the 2nd
element, and so on.
 You can assign values at the time of declaration: int numbers[5] = {10, 20, 30, 40, 50};
 If you don’t specify all values, the remaining elements will be set to 0: int numbers[5] = {10, 20} // numbers[2],
numbers[3], and numbers[4] are set to 0
INITIALIZING AN ARRAY
TYPES OF ARRAYS
 One-Dimensional Array:
1. Stores data in a single row, like {1, 2, 3, 4, 5}.
 Two-Dimensional Array:
1. Stores data in rows and columns, like a table: int matrix[2][3] = { {1, 2, 3}, {4, 5, 6} };
SUMMARY
Arrays store multiple values in a single variable.
Each element in an array has a unique index.
 Arrays help manage data efficiently and are useful in programs involving multiple similar data items.
THANKYOU

ARRAY (specially for computer science students).pptx

  • 1.
  • 2.
    WHAT IS ANARRAY?  An array is a collection of variables of the same data type.  Stores data in a single variable rather than using separate variables for each value.  Helps in organizing data in an ordered format.
  • 3.
    WHY USE ARRAYS? Arrayshelp to store multiple values together, saving time and space. Useful for managing large sets of similar data, like scores, marks, or names.  Makes programs more organized and efficient.
  • 4.
    ARRAY SYNTAX  Syntaxto declare an array : data type array name [array size];  Example: int numbers[5]; int: data type of the array elements, Numbers: name of the array, [5]: size of the array (can store 5 integers).
  • 5.
    HOW ARRAY ELEMENTSARE STORED ? Array elements are stored in contiguous (continuous) memory locations. Each element can be accessed using an index: Index starts at 0. Example: numbers[0] is the 1st element.  Numbers[1] is the 2nd element, and so on.
  • 6.
     You canassign values at the time of declaration: int numbers[5] = {10, 20, 30, 40, 50};  If you don’t specify all values, the remaining elements will be set to 0: int numbers[5] = {10, 20} // numbers[2], numbers[3], and numbers[4] are set to 0 INITIALIZING AN ARRAY
  • 7.
    TYPES OF ARRAYS One-Dimensional Array: 1. Stores data in a single row, like {1, 2, 3, 4, 5}.  Two-Dimensional Array: 1. Stores data in rows and columns, like a table: int matrix[2][3] = { {1, 2, 3}, {4, 5, 6} };
  • 8.
    SUMMARY Arrays store multiplevalues in a single variable. Each element in an array has a unique index.  Arrays help manage data efficiently and are useful in programs involving multiple similar data items.
  • 9.