Join the social network of Tech Nerds, increase skill rank, get work, manage projects...

• # Program to sort elements in Ascending Order using Selection Sort in C language

• 0
• 1
• 0
• 0
• 0
• 0
• 1
• 0
• 364
Comment on it

Program to sort elements in Ascending Order using Selection Sort in C language

Selection Sorting
Definition:- It compare the array of number with the rest of number in the array list & takes the selected to the top of the list & again compare another second lowest number & so on until we get the sorted number array.

```//Header Files
#include<stdio.h>
#include<conio.h>

void main()
{
int n, i, j, k, pass, min, arr[20]; //variables
clrscr();            //to clear screen
// User to input the limit of the array
printf("\n Enter the number limit:-");
scanf("%d",&n);                // To scan the limit of the array
//Asking user to input the elements of the array
printf("\n Enter the element to be sorted:->\n");
for(i=0;i<n;i++)
scanf("%d", &arr[i]);  //Scanning the elements in the array

for(pass=0; pass<n-1;pass++)
{
min=pass;
for(j=pass+1;j<n;j++)
{
if(arr[min]>arr[j])   //Comparing array elements
min=j;
}
if(min!=pass)  // verifying the elements
{                    //Swapping the elements
k=arr[pass];
arr[pass]= arr[min];
arr[min]=k;
}
}
printf("\n Element for Selection sort are:-");
for(i=0;i<n;i++)
{
printf("\n%d",arr[i]);  //Printing the Sorted array
}
getch();
}
```

Output:-

```Enter the number limit:-6

Enter the element to be sorted:->
9
4
6
2
0
1

Element for Selection sort are:-
0
1
2
4
6
9
```

## 0 Comment(s)

OR
OR
Register

OR
Fill out the form below and instructions to reset your password will be emailed to you:

• Hire
• Post Projects

### Post Projects

• All at 0 Cost ....
• Post Tech Job
• Select Best Bidder
• Track the Project
• Approve Work and Pay safely
• Browse Nerds
• Work
• Find Projects Find Projects
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
• Manage
• Company Company

### Manage Company

• All at 0 Cost ....
• Manage Company and Employee Profiles
• Company wide Employee Productivity Reports
• Knowledge Sharing and Collaboration Tools
• Get Sales Lead and Bid for Tech Projects
• Send Invoices and Receive Payment Safely
• Learn
• Nerd Digest Nerd Digest
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
• Tech Q & A Tech Q & A
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General