program for sorting array using selection sort technique || in c programming language
program for sorting array using selection sort technique
#include<stdio.h>
#include<conio.h>
#define size 10
/* you can define the size according to your choice */
void main()
{
int arr[size];
int i,j,temp;
printf("enter array elements : ");
for(i=0;i<size;i++)
{
scanf("%d",&arr[i]);
}
for(i=0;i<size-1;i++)
{
for(j=i+1;j<size;j++)
{
if(arr[i]>arr[j])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
printf("sorted array is: \n");
for(i=0;i<size;i++)
{
printf("%d",arr[i]);
}
getch();
}
Comments
Post a Comment