Question #260989

The purpose of a sorting algorithm is to order/categorize set of items within a series of items.


Write a program/method to swap two neighboring numbers in an array when the first index is given.

Expert's answer

void swapTwoNumbers(int numbers[],int firstIndex)
{
    int temp = numbers[firstIndex];
    numbers[firstIndex] = numbers[firstIndex+1];
    numbers[firstIndex+1] = temp;
}

LATEST TUTORIALS
APPROVED BY CLIENTS