C Lesson 45 – DSA Mini Project | Dataplexa

DSA Mini Project in C

Congratulations 🎉 You have reached the final lesson of the Data Structures & Algorithms section.

So far, you have learned:

  • Arrays, linked lists, stacks and queues
  • Trees and binary search trees
  • Sorting and searching algorithms
  • Basic graph concepts

In this lesson, we will combine multiple concepts into one meaningful mini project.


Project Title

Student Record Search System

This project simulates how real systems store and search data efficiently.


Project Requirements

  • Store student roll numbers in an array
  • Sort the data using a sorting algorithm
  • Search a student using binary search
  • Display results clearly

Step 1: Sample Data

We will work with student roll numbers:


int students[6] = {45, 12, 78, 34, 23, 56};

Step 2: Sorting the Data

We first sort the array using Bubble Sort.


void bubbleSort(int a[], int n) {
    int i, j, temp;
    for (i = 0; i < n - 1; i++) {
        for (j = 0; j < n - i - 1; j++) {
            if (a[j] > a[j + 1]) {
                temp = a[j];
                a[j] = a[j + 1];
                a[j + 1] = temp;
            }
        }
    }
}

Step 3: Searching the Student

Now we apply binary search.


int binarySearch(int a[], int n, int key) {
    int low = 0, high = n - 1, mid;

    while (low <= high) {
        mid = (low + high) / 2;

        if (a[mid] == key)
            return mid;
        else if (key < a[mid])
            high = mid - 1;
        else
            low = mid + 1;
    }
    return -1;
}

Step 4: Complete Program


#include <stdio.h>

void bubbleSort(int a[], int n);
int binarySearch(int a[], int n, int key);

int main() {
    int students[6] = {45, 12, 78, 34, 23, 56};
    int key, pos;

    bubbleSort(students, 6);

    printf("Enter roll number to search: ");
    scanf("%d", &key);

    pos = binarySearch(students, 6, key);

    if (pos != -1)
        printf("Student found at position %d", pos + 1);
    else
        printf("Student not found");

    return 0;
}

What You Practiced in This Project

  • Array manipulation
  • Sorting logic
  • Binary search
  • Modular programming
  • Real-world thinking

Mini Practice

  • Add student names using structures
  • Allow searching by name
  • Display sorted records