911 Help needed please!!!!
So the code below should make my array print out in descending order correct like 10,9,8,7,6,5,4,3,2,1
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
|
if (userinput == 2)
{
int i, next;
for(i = 0; i < arraysize; i++);
{
for(next = i + 1; next < 10; next++)
{
if(uservalue[i] < uservalue[next])
{
//Exchange them
int temp = uservalue[i];
uservalue[i] = uservalue[next];
uservalue[next] = temp;
}
}
}
for (int i = 0; i < arraysize; i++)
{
cout << uservalue[i] << endl;
}
cout << "Highest number is \n" << uservalue[0] << endl;
cout << "Lowest number is \n" << uservalue[9] << endl;
int total=0;
for(int i=0; i<10; i++)
{
total = total+uservalue[i];
}
cout << "The average is \n" << total/arraysize << endl;
}
| |
Topic archived. No new replies allowed.