Skip to content

Bug in BubbleSort.c #396

Open
Open
@ashwek

Description

@ashwek

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions