C Program to Sort Random Array Using Bubble Sort and rand() function
Problem:
Write a c program for bubble sort on random array.Algorithm or Solution:
This program sorts a random array of n integers (accept the value of n from user) in ascending order by using bubble sort algorithm.Here is the solution of c program to sort random array using bubble sort.
C Program / Source Code:
Here is the source code of C program for bubble sort on random array./* Aim: Write a C program to sorting a random array using bubble sort. */ #include<stdio.h> #include<stdlib.h> // Function to generate random array void generate(int *a,int n) { int i; for(i=0;i// Passing starting address and size to generate random array // Displaying the random array printf("\n The random array: "); for(i=0;i // Displaying the sorted array. printf("\n The sorted array: "); for(i=0;i /* Output of above code:- Enter size of array:- 5 The random array: 83 86 77 15 93 The sorted array: 15 77 83 86 93 */