#include<stdio.h>
#include<conio.h>
void selection(int *p, int n)
{
int i, j, min, minp, tmp;
for(i=0;i<n;i++)
{
min = *(p+i);
minp = i;
for(j=i+1;j<n;j++)
{
if(min>*(p+j))
{
min = *(p+j);
minp = j;
}
}
tmp = *(p+i);
*(p+i) = *(p+minp);
*(p+minp) = tmp;
}
}
void main()
{
int a[10], i, j, tmp;
clrscr();
printf("nEnter the values for the array:");
for(i=0;i<10;i++)
{
scanf("%d", &a[i]);
}
selection(&a[0], 10);
printf("nSorted Values are:");
for(i=0;i<10;i++)
{
printf("n%d", a[i]);
}
getch();
}
Write a program in C to input an array of size 10 and pass its address to a function Selection which sorts it in ascending order by Selection Sort Method. Print the resulting matrix
Programming