Select Git revision
histo.c 840 B
/* Author : Dario GENGA
* Date : 15.11.2021
* Description : Manipulate an unidimensional array with dynamic memory allocation
*/
#include "unidimensional_array.h"
int main() {
// Ask the user the size of the array
size_t array_size = ask_array_size();
int *array = malloc(array_size * sizeof(int));
// Fill the array with random values
fill_array_with_random_values(array, array_size);
// Find the lowest value in the array
int lowest_value = find_lowest_value_in_array(array, array_size);
printf("Lowest value : %d\n", lowest_value);
// Swap the highest value of the array with the last element of the array
size_t index_highest_value = find_index_highest_value_in_array(array, array_size);
swap(&array[index_highest_value], &array[array_size - 1]);
free(array);
return 0;
}