Program to arrange the elements of an array using Bubble Sort

Program to arrange the elements of an array using Bubble Sort

#include <stdio.h>
#include <conio.h>
void main()
{
int A[10], i, j, n, temp;
clrscr();

printf ("Enter the number of elements: ");
scanf ("%d", &n);

printf ("Enter the data: ");
for ( i=0; i<n; i++ )
{
scanf ("%d", &A[i]);
}

for ( i=0; i<n; i++ )
{
for ( j=0; j<n-i; j++ )
{
if ( A[j] > A[j+1])
{
temp = A[j];
A[j] = A[j+1];
A[j+1]=temp;
}
}
}

printf ("Sorted Array is "); //Sorted in Ascending Order
for ( i=0; i<n; i++ )
{
printf ("%d\t", A[i]);
}

getch();
}