0% found this document useful (0 votes)
3 views2 pages

Bubbel Sort

Uploaded by

oldxmonk49
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Bubbel Sort

Uploaded by

oldxmonk49
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

/* SY CSE 2024-25 Name: Akshay Rajendra

Sonwane Roll No: 65 Batch: S4

Program 10= Implementation of bubble sort


#include <stdio.h>

#include<conio.h>

void swap(int *a, int *b) {

int temp = *a;

*a = *b;

*b = temp;

voidbubbleSort(intarr[], int n) {

int i, j;

for (i = 0; i < n - 1; i++) {

for (j = 0; j < n - i - 1; j++) {

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

swap(&arr[j], &arr[j + 1]);

voidprintArray(intarr[], int size) {

int i;

for (i = 0; i < size; i++) {

printf("%d ", arr[i]);


}

printf("\n");

void main() {

intarr[] = {64, 34, 25, 12, 22, 11, 90};

int n = sizeof(arr) / sizeof(arr[0]);

clrscr();

printf("Original array: ");

printArray(arr, n);

bubbleSort(arr, n);

printf("Sorted array: ");

printArray(arr, n);

//return 0;

getch();

Output=

You might also like