codezilla
codezilla copied to clipboard
Bug in BubbleSort.c
Describe the bug
in Sorting/Bubble Sort/C/BubbleSort.c
int arr[] = {6, 4, 5, 8, 2, 1, 9};
int n = sizeof(arr)/sizeof(arr[0]);
scanf("%d",&n);
<<---
bubbleSort(arr, n);
taking input of n
is not a good idea (unless user inputs the elements in the array too). If user enter a large value (larger than the actual size of array) program would print junk values and for sufficiently large value it can also crash the program.
To Reproduce Steps to reproduce the behavior:
- input any large value (larger than the actual size of the array)
Screenshots