#include <stdio.h>

int main(void)
{
     int arr[5] = {5,2,9,1,7};
    int minIndex = 0;

    for (int j = 1; j < 5; j++) {
        if (arr[j] < arr[minIndex]) {
            minIndex = j;
        }
    }
    int temp = arr[0];
    arr[0] = arr[minIndex];
    arr[minIndex] = temp;

    for (int i = 0; i < 5;i++ ) {
        printf("%d ",arr[i]);
    }
    return 0;
}
 

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: