Completely Solved C, C++ Programs Assignment.




C Program to sort the entered numbers using bubble sort

Filed Under:

Problem 48. C Program to sort the entered numbers using bubble sort.
#include<stdio.h>
#include<conio.h>
main( )
{
int a[100],i,j,n,t;
clrscr( );
printf(“enter the array size”);
scanf(“%d”,&n);
for(i=1;i<n;i++)
scanf(“%d”,&a[i]);
for(i=1;i<=n;i++)
for(j=i+1;j<n;j++)
if(a[i]>a[j])
{
t=a[i]
a[i]=a[j];
a[j]=t;
}
printf(“the sorted elements are “);
for(i=1;i<=n;i++)
print(“%d”,a[i]);
getch( );
}

C compiler: gcc 4.1.2

 Back to main directory: Sample C Program | Software Practical | Solved C Assignment


Get Free Programming Tutorials and Solved assignments