What purpose does the following code serves int main() { int array[] = {5, 3,…

PYQ CoCubes 2025

What purpose does the following code serves

int main()

{

int array[] = {5, 3, 1, 9, 8, 2, 4, 7};

int size = sizeof(array)/sizeof(array[0]);

int i, j, min_idx,temp;

for (i = 0; i < size-1; i++)

{

min_idx = i;

for (j = i+1; j < size; j++)

{

if (array[j] < array[min_idx])

min_idx = j;

}

temp = array[min_idx];

array[min_idx] = array[i];

array[i] = temp;}

  1. A.

    Finds some special element in the array

  2. B.

    Sorts the elements of array

  3. C.

    Finds the smallest element in the array

  4. D.

    None of the above

Attempted by 423 students.

Sign up free to check your answer

Sign up free

Explore the full course: Cdac C Cat Complete Preparation

Loading lesson…