-
Notifications
You must be signed in to change notification settings - Fork 0
/
pointer_functions.h
34 lines (27 loc) · 1.46 KB
/
pointer_functions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
========================================================================================
Author : Gabriel Hochmann
Date : August 20, 2024
File : pointer_functions.h
Source : Pointers in C (List of Exercises) - Professor Rômulo Silva
Description : A C header file that declares several functions for handling arrays and
performing operations using pointers.
========================================================================================
*/
#ifndef POINTERS_FUNCTIONS_H
#define POINTERS_FUNCTIONS_H
// Calculates the mode of an integer array 'v'with size 'n'.
// Returns the mode (most most frequent element) of the array.
int calculateMode(int *v, int n);
// Calculates various statistics for an integer array 'v' with size 'n'.
// Outputs: mode, smallest value, greatest value, and average via pointer parameter.
// Returns the sum of all elements in the array.
int calculate_statistics(int v[], int n, int *mode, int *smallest, int *greatest, float *average);
// Copies the contents of an integer array 'vetA' to another array 'vetB' with size 'n'.
void copy_vector(const int vetA[], int vetB[], int n);
// Clones the vector 'vet' of size 'n' and returns a dynamically allocated copy.
int *clone_vector(int vet[], int n);
// Compares and sorts three integer pointers 'a', 'b', and 'c' in ascending order.
// Returns 1 if all values are equal, 0 otherwise.
int comparator(int *a, int *b, int *c);
#endif // POINTERS_FUNCTIONS_H