Skip to content

C programming laboratory example demonstrating dynamic memory, arrays, pointers, and file handling through a combinations generator with user-defined constraints (Computer Programming, UNIWA).

Notifications You must be signed in to change notification settings

Computer-Programming-aka-Uniwa/Pointers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

UNIWA

UNIVERSITY OF WEST ATTICA
SCHOOL OF ENGINEERING
DEPARTMENT OF COMPUTER ENGINEERING AND INFORMATICS


Computer Programming

Arrays, Pointers, Files

Vasileios Evangelos Athanasiou
Student ID: 19390005

GitHub · LinkedIn

Supervisor: Georgios Meletiou, Laboratory Teaching Staff

UNIWA Profile

Athens, January 2022


Project Overview

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.


Table of Contents

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

1. Combinations.c

The Combinations.c program includes the following core functionalities:

Dynamic Data Input

  • Reads a set of N numbers (where 6 < N ≤ 49).
  • Ensures numbers fall within the valid range [1,49].

Constraint Setting

  • 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.

Memory Management

  • Uses dynamic memory allocation (malloc, calloc) for all major data structures.
  • Includes safety checks to verify successful memory binding.

Data Processing

  • 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.

Program Structure

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.

Technical Specifications

  • Language: C
  • Libraries: stdio.h (I/O operations), stdlib.h (memory management)
  • Data Structures: Dynamically allocated one-dimensional arrays (pointers)

Example Usage

If a user inputs 8 numbers:

2, 6, 7, 12, 21, 32, 43, 45

and sets:

  • Even number limit: 2 to 4
  • Sum limit: 21 to 141

the program will:

  1. Generate 28 total combinations.
  2. Filter combinations based on the constraints.
  3. Print the valid combinations and their frequency of occurrence.

Installation & Setup Guide

This repository contains introductory laboratory material for the
Computer Programming course at the University of West Attica (UNIWA).


Prerequisites

Required Software

  • C Compiler

    • Recommended:
      • GCC (Linux / macOS / Windows via MinGW or WSL)
  • Text Editor or IDE

    • Visual Studio Code (Recommended)
    • Code::Blocks
    • Dev-C++
    • CLion
    • Any plain text editor

Supported Operating Systems

  • Windows
  • Linux (Recommended)
  • macOS

Installation

1. Clone the Repository

Clone the repository to your local machine:

git clone https://github.com/Computer-Programming-aka-Uniwa/Pointers.git

Alternative (Without Git)

  • Open the repository URL in your browser
  • Click Code → Download ZIP
  • Extract the ZIP file to a local directory

Compiling & Running the Programs

2. Navigate to Source Directory

cd Pointers/src

3. Compile the Programs

gcc Combinations.c -o Combinations

4. Run the Programs

Linux / macOS

./Combinations

Windows

Combinations.exe

Open the Documentation

  1. Navigate to the docs/ directory
  2. Open the report corresponding to your preferred language:
    • English: Arrays-Pointers-Files.pdf
    • Greek: Πίνακες-Δείκτες-Αρχεία.pdf

About

C programming laboratory example demonstrating dynamic memory, arrays, pointers, and file handling through a combinations generator with user-defined constraints (Computer Programming, UNIWA).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages