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.
#include <stdio.h>
#define SIZE 10
void Input(constint 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(constint 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;
}