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

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UNIWA

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

University of West Attica · Department of Computer Engineering and Informatics


Computer Programming

Arrays, Pointers, Files

Vasileios Evangelos Athanasiou
Student ID: 19390005

GitHub · LinkedIn


Supervision

Supervisor: Nikolaos Vassilas, Professor

UNIWA Profile

Co-supervisor: Georgios Meletiou, Laboratory Teaching Staff

UNIWA Profile


Athens, January 2022



README

Arrays, Pointers, Files

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 Project documentation
5 INSTALL.md Usage instructions

1. Combinations.c

The Combinations.c program includes the following core functionalities:

1.1 Dynamic Data Input

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

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

1.3 Memory Management

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

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

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

3. Technical Specifications

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

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

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