Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions sorting/bubble_sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ void bubbleSort(int *arr, int size)
void test()
{
const int size = 10;
int *arr = (int *)calloc(size, sizeof(int));
int *arr = calloc(size, sizeof(int));
if (arr == NULL)
{
perror("Memory allocation failed");
exit(EXIT_FAILURE);
}

/* generate size random numbers from 0 to 100 */
for (int i = 0; i < size; i++)
Expand All @@ -86,9 +91,9 @@ void test()
}

/** Driver Code */
int main(int argc, const char *argv[])
int main(void)
{
/* Intializes random number generator */
/* Initializes random number generator */
srand(time(NULL));
test();
return 0;
Expand Down
Loading