Selection Sort

I'm trying to sort the numbers in an array from largest to smallest and print it but whenever I run this it does not sort anything at all and I can't figure out what I'm doing wrong.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <stdio.h>
#define SIZE 10

void Input(const int array1[]);
void Calculations(int array1[], int average);
void Output(int array1[], int average);

size_t counter1 = 0;
int average;

int main( void )
{
int array1[ SIZE ];




Input(array1);
Calculations(array1, average);
Output(array1, average);

}




void Input(const int array1[])
{
	for(counter1 = 0; counter1 < 10; counter1++)

		{
			printf("Enter an expected activity time: ");
			scanf("%i", &(array1[counter1]));
			
	}
	return;
}



void Calculations( int array1[], int length )
{
   int Largest; 
   int a; 
   int b;
   int c;
   int sum = 0;
   

   
   for ( a = 0; a < length - 1; a++ ) 
   {
      Largest = a; 
        
      
      for ( b = a + 1; b < length; b++ )
         if ( array1[ b ] > array1[ Largest ] )
            Largest = b;

   } /* end for */

   for ( c = 0 ; c < 10 ; c++)
   {
	sum += array1[c];

   }
   average = sum/10;
   return;


} 





void Output(int array1[], int average)
{
	int i;

	 
	
	for ( i = 0; i < 10; i++ ) 
	  {                   
      printf( "%7u%13d\n", i, array1[ i ] ); 
	  }
	
	printf("The average is %.00i\n", average);


	system("PAUSE");
	return;

}
Topic archived. No new replies allowed.