-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats.h
106 lines (98 loc) · 3.63 KB
/
stats.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/******************************************************************************
* Copyright (C) 2021 by Nilan Fernando
*
* Redistribution, modification or use of this software in source or binary
* forms is permitted as long as the files maintain this copyright.
*
*
*****************************************************************************/
/**
* @file stats.h
* @brief The header file
*
* This contains all the function declerations
*
* @author Nilan Fernando
* @date 11/09/2021
*
*/
#ifndef __STATS_H__
#define __STATS_H__
/**
* @brief Prints the array
*
* This function accepts two inputs namely, the array and its length as integer and prints the elements of the array line by line.
*
* @param arr[] This is of unsigned char type which is the array to be printed
* @param length This is the length of the array of int type
*
* @return This function prints the array to the screen
*/
void print_array(unsigned char arr[],int length);
/**
* @brief Calculates the mean
*
* This function accepts two inputs namely, the array and its length as integer and calculates the mean of the array elements by dividing the sum of elements by its length
*
* @param arr[] This is of unsigned char type which is the array to be printed
* @param length This is the length of the array of int type
*
* @return It returns the mean of the array elements
*/
float find_mean(unsigned char arr[],int length);
/**
* @brief Sorts the array
*
* This function accepts two inputs namely, the array and its length as integer and sorts the elements in the descending order
*
* @param arr[] This is of unsigned char type which is the array to be printed
* @param length This is the length of the array of int type
*
* @return This function sorts the array
*/
void sort_array(unsigned char arr[],int length);
/**
* @brief Calculates the median
*
* This function accepts two inputs namely, the array and its length as integer and calculates the median of the sorted array using the sort_array()
*
* @param arr[] This is of unsigned char type which is the array to be printed
* @param length This is the length of the array of int type
*
* @return It returns the median of the array elements
*/
float find_median(unsigned char arr[],int length);
/**
* @brief Calculates the maximum
*
* This function accepts two inputs namely, the array and its length as integer and calculates the maximum value of the array
*
* @param arr[] This is of unsigned char type which is the array to be printed
* @param length This is the length of the array of int type
*
* @return It returns the maximum value of the array
*/
float find_maximum(unsigned char arr[],int length);
/**
* @brief Calculates the minimum
*
* This function accepts two inputs namely, the array and its length as integer and calculates the minimum value of the array
*
* @param arr[] This is of unsigned char type which is the array to be printed
* @param length This is the length of the array of int type
*
* @return It returns the minimum value of the array
*/
float find_minimum(unsigned char arr[],int length);
/**
* @brief Prints statistics
*
* This function accepts two inputs namely, the array and its length as integer and prints all the statistics: mean,median,maximum and minimum values. This function calls the previously developed funtions locally to calculate these statistics and print them on screen
*
* @param arr[] This is of unsigned char type which is the array to be printed
* @param length This is the length of the array of int type
*
* @return This function prints the statistics to the screen.
*/
void print_statistics(unsigned char arr[],int length);
#endif /* __STATS_H__ */