EmbLogic's Blog

Program For selection Short

#include<stdio.h>
int main()
{
int i,j,n,small,k;
printf(“Enter the Element of Array\n”);
scanf(“%d”,&n);
int a[n];
printf(“Enter the element\n”);
for(i=0;i<n;i++)
{
scanf(“%d”,&a[i]);
}
for(i=0;i<n;i++)
{
small=i;
for(j=i;j<n;j++)
{
if(a[j]<a[small])
small=j;
}
k=a[small];
a[small]=a[i];
a[i]=k;
}
for(i=0;i<n;i++)
{
printf(“%d\n”,a[i]);
}
}

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>