UNIVERSITY OF WEST ATTICA
SCHOOL OF ENGINEERING
DEPARTMENT OF COMPUTER ENGINEERING AND INFORMATICS
Computer Programming
Vasileios Evangelos Athanasiou
Student ID: 19390005
Supervisor: Georgios Meletiou, Laboratory Teaching Staff
Athens, January 2022
The primary goal of the application is to process a set of numbers and generate all possible combinations of six numbers that satisfy specific user-defined constraints regarding the count of even numbers and the total sum of the combination.
| Section | Folder / File | Description |
|---|---|---|
| 1 | assign/ |
Assignment material |
| 1.1 | assign/project6_1.png |
Assignment 1 description (English) |
| 1.2 | assign/project6_2.png |
Assignment 2 description (English) |
| 1.3 | assign/εργασία6_1.png |
Assignment 1 description (Greek) |
| 1.4 | assign/εργασία6_2.png |
Assignment 2 description (Greek) |
| 2 | docs/ |
Theoretical documentation |
| 2.1 | docs/Arrays-Pointers-Files.pdf |
Arrays, pointers, and file handling (English) |
| 2.2 | docs/Πίνακες-Δείκτες-Αρχεία.pdf |
Arrays, pointers, and file handling (Greek) |
| 3 | src/ |
Source code implementations |
| 3.1 | src/Combinations.c |
Example using pointers and arrays for combinations |
| 4 | README.md |
Repository overview and instructions |
The Combinations.c program includes the following core functionalities:
- Reads a set of N numbers (where 6 < N ≤ 49).
- Ensures numbers fall within the valid range [1,49].
- Users can define filtering intervals for combinations:
- Even Numbers: Interval
[X1,X2]for allowed number of even digits. - Sum Range: Interval
[Y1,Y2]for the allowed total sum.
- Even Numbers: Interval
- Uses dynamic memory allocation (
malloc,calloc) for all major data structures. - Includes safety checks to verify successful memory binding.
- Sorts input numbers in ascending order before generating combinations.
- Calculates frequency of occurrence for each number in the filtered list.
- Reports statistics on how many combinations were filtered out by each condition.
The program is modular, consisting of specialized functions:
Read_N_Numbers(): Handles input for the total count of numbers.Read_Matrix(): Populates a dynamically allocated array with the user's numbers.Combos(): Core logic engine that generates combinations and applies filters.Search_Evens()&Search_Sum(): Validate the defined constraints.Frequency(): Tracks how often numbers appear in valid combinations.Free_Memory(): Frees all dynamically allocated memory upon completion.
- Language: C
- Libraries:
stdio.h(I/O operations),stdlib.h(memory management) - Data Structures: Dynamically allocated one-dimensional arrays (pointers)
If a user inputs 8 numbers:
2, 6, 7, 12, 21, 32, 43, 45and sets:
- Even number limit: 2 to 4
- Sum limit: 21 to 141
the program will:
- Generate 28 total combinations.
- Filter combinations based on the constraints.
- Print the valid combinations and their frequency of occurrence.
This repository contains introductory laboratory material for the
Computer Programming course at the University of West Attica (UNIWA).
-
C Compiler
- Recommended:
- GCC (Linux / macOS / Windows via MinGW or WSL)
- Recommended:
-
Text Editor or IDE
- Visual Studio Code
(Recommended) - Code::Blocks
- Dev-C++
- CLion
- Any plain text editor
- Visual Studio Code
- Windows
- Linux
(Recommended) - macOS
Clone the repository to your local machine:
git clone https://github.com/Computer-Programming-aka-Uniwa/Pointers.git- Open the repository URL in your browser
- Click Code → Download ZIP
- Extract the ZIP file to a local directory
cd Pointers/srcgcc Combinations.c -o CombinationsLinux / macOS
./CombinationsWindows
Combinations.exe- Navigate to the
docs/directory - Open the report corresponding to your preferred language:
- English:
Arrays-Pointers-Files.pdf - Greek:
Πίνακες-Δείκτες-Αρχεία.pdf
- English:
