/*
Write a program to accept 10 elements in array. Sort the elements in
ascending order using bubblesort algorithm.
*/
#include<stdio.h>
#include<conio.h>
void main()
{
int A[10],i,j,t=0;
clrscr();
printf("Enter 10 elements in array: \n");
for(i=0;i<10;i++)
{
scanf("%d",&A[i]);
}
//using bubblesort technique
for(i=0;i<10-1;i++)
{
for(j=0;j<10-i-1;j++)
{
if(A[j]>A[j+1])
{
t = A[j];
A[j]=A[j+1];
A[j+1]=t;
}
}
}
//display the elements
printf("\nThe sorted elements are:\n");
for(i=0;i<10;i++)
{
printf("\n%d",A[i]);
}
getch();
}
Write a program to accept 10 elements in array. Sort the elements in
ascending order using bubblesort algorithm.
*/
#include<stdio.h>
#include<conio.h>
void main()
{
int A[10],i,j,t=0;
clrscr();
printf("Enter 10 elements in array: \n");
for(i=0;i<10;i++)
{
scanf("%d",&A[i]);
}
//using bubblesort technique
for(i=0;i<10-1;i++)
{
for(j=0;j<10-i-1;j++)
{
if(A[j]>A[j+1])
{
t = A[j];
A[j]=A[j+1];
A[j+1]=t;
}
}
}
//display the elements
printf("\nThe sorted elements are:\n");
for(i=0;i<10;i++)
{
printf("\n%d",A[i]);
}
getch();
}