-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats.h
120 lines (100 loc) · 6.13 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/******************************************************************************
* Copyright (C) 2017 by Alex Fosdick - University of Colorado
*
* Redistribution, modification or use of this software in source or binary
* forms is permitted as long as the files maintain this copyright. Users are
* permitted to modify this and use it to learn about the field of embedded
* software. Alex Fosdick and the University of Colorado are not liable for any
* misuse of this material.
*
*****************************************************************************/
/**
* @file stats.h
* @brief This file header includes declarations and documentation for the functions from the stats.c file
*
* This file introduces the functions used in "stats.c". File stats.c introduces a couple of functions that can analyze an array of unsigned char data items and report analytics on the maximum, minimum, mean, and median of the data set. In addition,reorder the data set from large to small. All statistics are rounded down to the nearest integer. After analysis and sorting is done,prints that data to the screen in nicely formatted presentation.The stats.h header file includes declarations and documentation for the functions from the present file.
* @author <Somali Bhosale>
* @date <24/05/2020>
*
*/
#ifndef __STATS_H__
#define __STATS_H__
/**
* @brief printing all statistics calculated
*
* This function prints the calculated statistics like minimum,maximum,mean,median
accepting the parameters in unsigned character format; printing them in received format and
return nothing to main function.
*
* @param mean It is of data-type unsigned char repsenting mean value of test array elements
* @param max It is of data-type unsigned char repsenting maximum value of test array elements
* @param min It is of data-type unsigned char repsenting minimum value of test array elements
* @param med It is of data-type unsigned char repsenting median value of test array elements
*
* @return void
*/
void print_statistics(unsigned char mean,unsigned char max,unsigned char min,unsigned char med);
/**
* @brief Given an array of data and a length, prints the array to the screen
*
* This function take inputs as unsigned char pointer *test; here test holding the array address and unsigned char size holding the SIZE of
the array. Fuction prints the array data of specified size returning nothing to calling function
*
* @param *test It is pointer of type unsigned char where test is holding the address of parameter array
* @param size It is of data type unsigned char representing size of the array
*
* @return void
*/
void print_array(unsigned char *test,unsigned char size);
/**
* @brief Given an array of data and a length, returns the median value
* This function take inputs as unsigned char pointer *test; here test holding the sorted array address and unsigned char size holding the
SIZE of the array. Fuction finds the median value of the sorted array elements(performing sorting array operation before calling this
function). Returning calulated median value of array of the format unsigned char.
*
* @param *test It is pointer of type unsigned char where test is holding the address of sorted array
* @param size It is of data type unsigned char representing size of the array
* @return The median of sorted array elements of data-type unsigned char
*/
unsigned char find_median(unsigned char *test,unsigned char size);
/**
* @brief Given an array of data and a length, returns the mean
* This function take inputs as unsigned char pointer *test; here test holding the array address and unsigned char size holding the
SIZE of the array. Fuction finds the mean value of the array elements.Returning calculated mean value of array of the format unsigned char.
*
* @param *test It is pointer of type unsigned char where test is holding the address of parameter array
* @param size It is of data type unsigned char representing size of the array
* @return The mean of array elements of data-type unsigned char
*/
unsigned char find_mean(unsigned char *test,unsigned char size);
/**
* @brief Given an array of data and a length, returns the maximum
* This function take inputs as unsigned char pointer *test; here test holding the array address and unsigned char size holding the
SIZE of the array. Fuction finds the maximum value of the array.Returning calculated maximum value of array of the format unsigned char.
*
* @param *test It is pointer of type unsigned char where test is holding the address of parameter array
* @param size It is of data type unsigned char representing size of the array
* @return The maximum of array elements of data-type unsigned char
*/
unsigned char find_maximum(unsigned char *test,unsigned char size);
/**
* @brief Given an array of data and a length, returns the minimum
* This function take inputs as unsigned char pointer *test; here test holding the array address and unsigned char size holding the
SIZE of the array. Fuction finds the minimum value of the array.Returning calculated minimum value of array of the format unsigned char.
*
* @param *test It is pointer of type unsigned char where test is holding the address of parameter array
* @param size It is of data type unsigned char representing size of the array
* @return The minimum of array elements of data-type unsigned char
*/
unsigned char find_minimum(unsigned char *test,unsigned char size);
/**
* @brief Given an array of data and a length, sorts the array from largest to smallest. (The zeroth Element should be the largest value, and the last element (n-1) should be the smallest value. )
* This function take inputs as unsigned char pointer *test; here test holding the array address and unsigned char size holding the
SIZE of the array. Function sorts the array from largest to smallest returning nothing to calling function.
*
* @param *test It is pointer of type unsigned char where test is holding the address of parameter array
* @param size It is of data type unsigned char representing size of the array
* @return void
*/
void sort_array(unsigned char *test,unsigned char size);
#endif /* __STATS_H__ */