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 .
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 : :
OUTPUT : :
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 .
need an explanation for this answer? contact us directly to get an explanation for this answer