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

PYQ Accenture 2025PYQ Hexaware 2024

What purporse 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 specific element in the array

  2. B.

    Sort the elements of array

  3. C.

    Find the smallest element in the array

  4. D.

    None of the above

Attempted by 374 students.

Sign up free to check your answer

Sign up free

Explore the full course: Accenture Preparation

Loading lesson…