SORTING USING SELECTION SORT
SORTING USING SELECTION SORT
#include <stdio.h>
#include <conio.h>
int main()
{
int array[100], n, i, j, position, temp;
clrscr();
printf(“Enter number of elements : \n”);
scanf(“%d”, &n);
printf(“Enter %d integers\n”, n);
for (i= 0;i<n;i++)
scanf(“%d”, &array[i]);
for (i=0;i<(n-1);i++)
{
position = i;
for (j=i+1;j<n;j++)
{
if ( array[position] > array[j] )
position = j;
}
if ( position != i )
{
temp = array[i];
array[i] = array[position];
array[position] = temp;
}
}
printf(“Sorted list in ascending order:\n”);
for (i=0;i<n;i++)
printf(“%d\n”, array[i]);
getch();
return 0;
}
OUTPUT
Enter number of elements : 5
Enter 1 element :
40
10
30
60
20
Sorting list ascending order :
10
20
30
40
60
- install our bcanotesnepal application from playstore : BCA Notes NepalDo not forget to like our facebook page : www.facebook.com/bcanotesnepal
Facebook Groups https://www.facebook.com/groups/bcanotesnepal
Join In our Facebook Group https://www.facebook.com/groups/1200219363518714/
if you need a Downloadable link once message us on-page you can get at a time.
This post is posted for not further third-party purposes.
Copyright By:- Bcanotesneapl
Not allow to upload this notes in other sites.
Like our Facebook Page https://www.facebook.com/bcanotesnepal/
if you want to download this PDF comment on us we will provide you a downloadable link.
if you like please share this post with your friend who studies in BCA
if you have any query please comment below,
if you like our sites. you can visit again for the latest updates notes of different BCA subject of Presentation and different topics with assignment question and solution.
Don’t forget to like our page and post also share with your friend and having your group.
if you have any questions you can drop or share them with me using the comment box I will try to give an answer to your question.
Like our Facebook Page https://www.facebook.com/bcanotesnepal/