UdaanPath Logo UdaanPath

📖 Chapters

Data Structures and Algorithms in C  (DSA)

Data Structures and Algorithms in C (DSA)

Category: IT Fundamentals & Programming

This course is designed to help learners master the core concepts of Data Structures and Algorithms (DSA) using the C programming language. Starting from the basics and advancing to complex topics like graphs, dynamic programming, and memory optimization, this course …

Arrays: Basics and Operations

📘 Arrays – Basics and Operations

Arrays are the most fundamental data structure in programming. They provide a way to store multiple values of the same type in a contiguous block of memory. In C, arrays are zero-indexed and require fixed size at compile time (unless dynamically allocated).

📦 What is an Array?

An array is a collection of elements of the same data type placed in contiguous memory locations and accessed using an index.

// Declaration & Initialization
int marks[5]; // declares array of size 5
int scores[5] = {80, 90, 85, 75, 95};
  

📌 Accessing Array Elements

  • Index starts at 0
  • scores[2] gives 3rd element → 85
  • Can be updated: scores[0] = 100;

🔁 Traversing an Array

for (int i = 0; i < 5; i++) {
    printf("%d ", scores[i]);
}
  

📊 Real-Life Example (UdaanPath)

Suppose UdaanPath is storing marks of 5 students in an online quiz:

int student_marks[5] = {80, 75, 90, 85, 70};
int total = 0;
for (int i = 0; i < 5; i++) {
    total += student_marks[i];
}
float average = total / 5.0;
printf("Average Marks = %.2f", average);
  

🔢 Types of Arrays

  • 1D Array: Simple linear list (e.g., int arr[10];)
  • 2D Array: Matrix format (e.g., int arr[3][3];)
  • Multidimensional Array: Higher dimensional data like 3D arrays

🧮 2D Array Example

int matrix[2][3] = {
  {1, 2, 3},
  {4, 5, 6}
};

for (int i = 0; i < 2; i++) {
  for (int j = 0; j < 3; j++) {
    printf("%d ", matrix[i][j]);
  }
  printf("\n");
}
  

⚙️ Array Operations

  • Insertion
  • Deletion (logical only, actual size fixed)
  • Traversal
  • Searching (Linear or Binary)
  • Updating values

📌 Limitations of Arrays

  • Fixed size → need to know size at compile time
  • Insertion/deletion is costly (O(n) time)
  • Not suitable when frequent resizing is required → use linked lists

📚 Practice Tasks

  • Find the max and min in an array of 10 integers
  • Write a function to reverse an array in-place
  • Count how many even numbers are in the array
  • Insert a value at a specific index in an array

✅ Summary

  • Arrays are fundamental and efficient for fixed-size collections
  • Best suited for random access and indexing
  • For dynamic memory, consider using pointers and malloc

📤 Coming Next

Next, we’ll dive into Strings in C — learn how to work with character arrays and manipulate text efficiently.

ECHO Education Point  📚🎒

ECHO Education Point 📚🎒

ECHO Education Point proudly presents its Full Stack Development program 💻 – designed to launch your career in tech!

  • 🚀 Master both Front-End and Back-End technologies
  • 🧪 Includes 11 Mock Tests, 35 Mini Projects & 3 Website Builds
  • 🎯 Special training for job interviews & placement preparation

📍 Location: D-Mart Road, Meghdoot Nagar, Mandsaur
📞 Contact: 8269399715

Start your coding journey with expert instructor Vijay Jain (B.C.A., M.Sc., M.C.A.)
10 Days Free Demo Classes – Limited seats available!

#ECHO #FullStackDevelopment #MandsaurCoding