Thanks that fixed all the errors now the program is not sorting the numbers in the array it is just printing them in the order I input them. Any ideas why? Here is the new source code:
Code:
// Array.cpp : Defines the entry point for the console application.
//
#include<stdio.h>
#include<stdafx.h>
#include"conio.h"
#include<math.h>
#define x 10
int arr[x], n, temp;
int get_min_range(int list[], int first, int last)
{
first=0;
for(last=1; last<x; ++last)
if (arr[last],arr[first])
first=last;
return(first);
}
void sort_arr(int arr[], int n)
{
int f, temp=0, index_of_min;
for (f = 0; f < x-1; ++f)
index_of_min = get_min_range(arr, f, x-1);
if (f != index_of_min)
temp = arr[index_of_min];
arr[index_of_min] = arr[f];
arr[f] = temp;
}
int main()
{
int f=0;
for(int n=0; n<x; n++)
{
printf("Enter a number in the array:");
scanf_s("%d", &arr[n]);
}
sort_arr( arr, n);
for(f=0; f<x; f++)
printf("%d", arr[f]);
getch();
return (0);
}