EmbLogic's Blog

using bubble sorting a prog to make elements in accending order….

#include<stdio.h>
int main()
{
int i,j,b,k,n,l;

printf(“\n\nenter the number of values u will enter : “);
scanf(“%d”,&n);

int a[n];

printf(“\nnow enter the elements : \n”);

for(l=0;l<n;l++)
{
scanf(“%d”,&a[l]);
}
for(i=0;i<n;i++)
{
for(j=0;j<n-1;j++)
{
if(a[j]>a[j+1])
{
b=a[j];
a[j]=a[j+1];
a[j+1]=b;
}
}
}
for(k=0;k<n;k++)
{
printf(“\n%d”,a[k]);
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>