BubbleSort_Output
BubbleSort_Output
#include <stdio.h>
#include <stdlib.h>
int data;
} NODE;
void create() {
int data = 1;
scanf("%d", &data);
while (data != 0) {
newnode->data = data;
newnode->next = NULL;
if (head == NULL) {
head = newnode;
} else {
ptr = head;
ptr->next = newnode;
scanf("%d", &data);
void bubble_sort() {
int temp;
temp = i->data;
i->data = j->data;
j->data = temp;
void display() {
NODE *temp = head;
temp = temp->next;
printf("\n");
void bubblesortarray() {
int a[20], n, i, j;
scanf("%d", &n);
scanf("%d", &a[i]);
a[j + 1] = temp;
}
}
printf("Sorted array:\n");
printf("\n");
int main() {
int ch;
do {
scanf("%d", &ch);
switch (ch) {
case 1:
bubblesortarray();
break;
case 2:
create();
display();
bubble_sort();
display();
break;
default:
return 0;
Expected Output:
1. For Array:
34 12 5 67 89
Sorted array:
5 12 34 67 89
Before Sorting: 45 23 78 12
After Sorting: 12 23 45 78