#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define SIZE 10
// Function to perform Bubble Sort
void bubbleSort(int arr[], int n) {
int i, j, temp;
for (i = 0; i < n - 1; i++) {
for (j = 0; j < n - i - 1; j++) {
// Swap if the element found is greater than the next element
if (arr[j] > arr[j + 1]) {
temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
}
// Function to print the array
void printArray(int arr[], int n) {
for (int i = 0; i < n; i++) {
printf("%d ", arr[i]);
}
printf("\n");
}
int main() {
int arr[SIZE];
// Seed the random number generator
srand(time(0));
// Generate 10 random numbers and store them in the array
for (int i = 0; i < SIZE; i++) {
arr[i] = rand() % 100; // Random number between 0 and 99
}
printf("Original Array: \n");
printArray(arr, SIZE);
// Sort the array using bubble sort
bubbleSort(arr, SIZE);
printf("\nSorted Array: \n");
printArray(arr, SIZE);
return 0;
}