Semester : S1 and S2
Subject : Computer Programming
Year : 2018
Term : MARCH
Branch : BIOTECHNOLOGY
Scheme : 2015 Full Time
Course Code : CS 100
Page:28
24.a)
void selection(int [], int, int, int, int);
int main()
{
int list{30], 926, temp, 1, |
printf("Enterthe size of the list: ")
scanf("%d" &size);
printf("Enter the elements in list:\n");
for (i = O; i < size; i++)
scanf("%d", &list[i]);
} selection(list, 0, 0, size, 1); printf("The sorted list in
ascending order is\n"); for (i = 0; i< size; i++)
{
printf("%d ", list[i]);
}
return 0;
}
void selection(int list[], int i, int j, int size, int flag)
{
int temp; if (1 ಆ
size - 1)
{
if (flag) 1
15121) } (|<
size) {
if (list [i] > list[j])
{
temp = list[i];
list[i] = list [j];
list[j] = temp;
] selection(list, i, | +
1, size, 0);
}
selection(list, i+1, 0, size, 1);
}
}