C Program to sort an array using Bubble Sort using functions

Program

#include<stdio.h>
void bubble_sort(int [], int);
void main()
{
	int arr[30], num, i;
	printf("Enter no of elements:\t");
	scanf("%d", &num);
	printf("Enter array elements:\n");
	for (i = 0; i < num; i++)
		scanf("%d", &arr[i]);
	bubble_sort(arr, num);
}
void bubble_sort(int arr[], int num)
{
	int i, j, k, temp;
	for (i = 1; i < num; i++)
	{
		for (j = 0; j < num - i - 1; j++)
		{
			if (arr[j] > arr[j + 1])
			{
				temp = arr[j];
				arr[j] = arr[j + 1];
				arr[j + 1] = temp;
			}
		}
	}
	printf("Sorted array elements:\n");
	for(i = 0; i < num; i++)
		printf("%d\n", arr[i]);
}

Output

Enter no of elements:	6
Enter array elements:
1
99
357
57
83
21
Sorted array elements:
1
21
57
83
99
357