codezilla icon indicating copy to clipboard operation
codezilla copied to clipboard

Bug in BubbleSort.c

Open ashwek opened this issue 6 years ago • 0 comments

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:

  1. input any large value (larger than the actual size of the array)

Screenshots Output Screenshot

ashwek avatar Nov 16 '18 13:11 ashwek