By | 27.11.2016

# Sort Numbers using Selection sort

Write a C Program to Sort Numbers using Selection sort. Here’s simple C Program to Sort Numbers using Selection sort in C Programming Language.

Below is the source code for C Program to Sort Numbers using Selection sort which is successfully compiled and run on Windows System to produce desired output as shown below :

## SOURCE CODE : :

```/*  C Program to Sort Numbers using Selection sort  */

#include <stdio.h>

int main()
{
int A[20], N, Temp, i, j;
printf("\nENTER THE NUMBER OF TERMS...: ");
scanf("%d",&N);
printf("\nENTER THE ELEMENTS OF THE ARRAY...: \n");
for(i=1; i<=N; i++)
{
printf("\nENTER THE ELEMENT [ %d ]...: ",i);
scanf("%d", &A[i]);
}
for(i=1; i<=N-1; i++)
for(j=i+1; j<=N;j++)
if(A[i]>A[j])
{
Temp = A[i];
A[i] = A[j];
A[j] = Temp;
}

printf("\nTHE SORTED LIST IS...: \n\n");
for(i=1; i<=N; i++)
printf(" %d ",A[i]);

printf("\n");

return 0;
}```

### OUTPUT : :

```/*  C Program to Sort Numbers using Selection sort  */

ENTER THE NUMBER OF TERMS...: 6

ENTER THE ELEMENTS OF THE ARRAY...:

ENTER THE ELEMENT [ 1 ]...: 4

ENTER THE ELEMENT [ 2 ]...: 1

ENTER THE ELEMENT [ 3 ]...: 3

ENTER THE ELEMENT [ 4 ]...: 5

ENTER THE ELEMENT [ 5 ]...: 7

ENTER THE ELEMENT [ 6 ]...: 9

THE SORTED LIST IS...:

1  3  4  5  7  9

Process returned 0```

Above is the source code for C Program to Sort Number using Selection sort which is successfully compiled and run on Windows System.The Output of the program is shown above .

If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach up to you in short interval.

4 1 vote
Article Rating
Category: C Programming Sorting Programs Tags: