0% found this document useful (0 votes)
4 views11 pages

Array in C Programming

Uploaded by

himangku82
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views11 pages

Array in C Programming

Uploaded by

himangku82
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Array in C Programming

Understanding Arrays and Their Applications

Presented By: Himangku Kalita & Ankur Roy


BCA 2nd SEM

1
INTRODUCTION
•An array is a collection of elements of the same data type,
stored contiguously in memory.

•Arrays help store multiple values using a single variable


name.

•Useful when dealing with large sets of data, such as student


marks, temperatures, etc.

2
TYPES OF ARRAYS
•1D Array: Linear collection of elements (like a list)

•2D Array: Array of arrays (like a table or matrix)

•Multidimensional Arrays: More than two dimensions, rarely used in basic programs

•Example:

•1D: int a[5];

•2D: int b[3][3];

3
One-Dimensional Array
• A single-dimensional array is a linear structure of
elements in C, where each element stores data of the
same data type and can be accessed using an index.
• Here the memory is allocated contiguously.
• Syntax:
data_type array_name[size];
• Initialization:
• int marks[5] = {90, 85, 78, 92, 88};

4
Two-Dimensional Array
• A two-dimensional (2D) array is a data structure that
organizes elements into a table-like grid with rows and
columns. It's essentially an array of arrays, allowing you to
store data in a structured, rectangular format.
• Syntax:
data_type array_name[row][column];
• Initialization:
int matrix[2][3] = {
{1, 2, 3},
{4, 5, 6}
};
5
Traversal: Visiting all elements

Common Insertion: Adding elements (in


static arrays, difficult after
Operatio declaration)

ns on Deletion: Removing elements


(shift elements manually)
Arrays
Searching: Linear or Binary Search

Update: Changing value at a


specific index

6
Limitations of Arrays

Fixed Size: Must define size during declaration

Cannot grow or shrink during runtime


No built-in bounds checking (can access invalid
indexes)
Inefficient for insertion/deletion

7
Storing multiple values of same type

Used in sorting and searching


algorithms

Applications Useful in mathematics (matrix

of Arrays operations)

Basic form of strings (character arrays)

Widely used in loops and functions

8
Find Maximum in Array:

• int max = arr[0];


• for(int i = 1; i < n; i++) {
• if(arr[i] > max) max = arr[i];
Real-Life • }

Example Average of Marks:


Programs • float avg = 0;
• for(int i = 0; i < 5; i++) {
• avg += marks[i];
• }
• avg = avg / 5;

9
References

Websites: Books:
GeeksforGeeks Programming with C by
TutorialsPoint T Jayapoovan.

10
THANK YOU

11

You might also like