c program :
#include <stdio.h>
int main()
{
int golam[' '], t, a, u, s, i, f, smallest, temp;
printf("enter the size of your array : ");
scanf("%d", &t);
for (i = 0; i < t; i++)
{
printf("enter your %d no. element :", i);
scanf("%d", &golam[i]);
}
printf("your un sorted array is :");
for (i = 0; i < t; i++)
{
printf("%d-", golam[i]);
}
printf("\nshorting your array in selaction short tecnic .......\n");
for (i = 0; i < t - 1; i++)
{
smallest = i;
for (u = i + 1; u < t; u++)
{
if (golam[smallest] > golam[u])
{
smallest = u;
}
}
temp = golam[smallest];
golam[smallest] = golam[i];
golam[i] = temp;
}
printf("your shorted array is : ");
for (i = 0; i < t; i++)
{
printf("%d", golam[i]);
}
}
Comments