This project implements a data processing algorithm in C designed to analyze specific segments of an integer array based on index parity. It calculates the statistical mean of a subset and filters data based on that metric.
The algorithm processes a dataset
First, it calculates the arithmetic mean (
In the second pass, the algorithm filters and prints elements
- Data Structure: Static Integer Array.
- Optimization: The loop increments by 2 (
i += 2) to directly target odd indices, avoiding unnecessary modulo (%) checks for every element. - Precision: Uses
doublefor the average calculation to ensure floating-point accuracy.
- Compile the code:
gcc main.c -o index_filter
- Run the executable:
./index_filter
Input Array: { 20, 60, 45, 42, 23, 24, 26, 125, 66, 55, 145, 50, 30, 40 }
- Target Indices: 1 (60), 3 (42), 5 (24), 7 (125)...
- Calculated Mean: ~56.57
- Output (Values > Mean):
60 125 50(Example approximation)
This repository demonstrates array indexing strategies and conditional filtering in C.