Thanks for your advice
I am still having trouble - I read the article that you provided the link for and I have been working on this for quite some time now (about 6 hours since I got the reply - but in that time I have done some research and more reading). I have altered my code but I still have a problem - I cannot figure out what is wrong with the line:
Code:
// arrange array in ascending order
for ( int i = 0; i < n; i++ )
I get the message for this line: ISO C++ forbids comparison between (this is in Dev C++)
here is my full code I have so far now:
Code:
#include <stdio.h> // for library function: printf
// function main begins program execution
main()
{
int i; // counter
int swap = 0;
float n[10]; // n is an array of floats
float sum = 0; // sum of the array
float temp, average, smallest, largest;
// initialise elements of array to 0
for ( i = 0; i < 10; i++ )
{
n[i] = 0; // set element at location i to 0
} // end for
printf( "Enter 10 float numbers:\n" );
scanf( "%f", &n[10] );
// sum of contents of array n
for ( i = 0; i < 10; i++ )
{
sum += n[i];
} // end for
// average of contents of array n
for ( i = 0; i < 10; i++ )
{
sum / 10;
} // end for
// arrange array in ascending order
for ( int i = 0; i < n; i++; ) // second attempt
// 1st try - for ( int i = 0; i < (n - 1); i++ )
{
if ( n[i] > n[i + 1] )
{
temp = n[i];
n[i] = n[i + 1];
n[i + 1] = temp;
swap = 1;
} // end if
while (swap !=0);
} // end for
// smallest number in array n
//**I have not done this as yet**
// largest numnber in array n
//**I have not done this as yet**
printf( "The sum of array n is %f\n", sum );
printf( "The avarage of array n is %f\n", average );
printf( "The array in ascending order is %f\n", n[10] );
//printf( "The smallest number of array n is %f\n", smallest );
//printf( "The largest number of array n is %f\n", largest );
return 0; // indicates successful termination
} // end function main
Any input would be appreciated
Thankyou