C icon indicating copy to clipboard operation
C copied to clipboard

update bubbleSort by lim chun hong

Open JimLCH opened this issue 2 years ago • 1 comments

I have updated the iterated loop and enhanced the program with additioanal code for the program effectiveness bubble sort

JimLCH avatar Jun 04 '22 04:06 JimLCH

#include <stdio.h>

int main(){

int arr[50], num, x, y, temp;    

printf("Please Enter the Number of Elements you want in the array: ");

scanf("%d", &num);    

printf("Please Enter the Value of Elements: ");

for(x = 0; x < num; x++)

    scanf("%d", &arr[x]);

for(x = 0; x < num - 1; x++){       

    for(y = 0; y < num - x - 1; y++){          

        if(arr[y] > arr[y + 1]){               

            temp = arr[y];

            arr[y] = arr[y + 1];

            arr[y + 1] = temp;

        }

JimLCH avatar Jun 18 '22 05:06 JimLCH