# Help cant figure this out

Discussion in 'Homework Help' started by PrincoPrince, Feb 12, 2015.

1. ### PrincoPrince Thread Starter New Member

Feb 12, 2015
10
0
Write a c++ program to accept ten integer values in an array in descending order.
NB: The input of the elements is via keyboard.

2. ### ErnieM AAC Fanatic!

Apr 24, 2011
7,436
1,626
Howdy. This looks like a homework assignment, so what have you done to solve this?

You show your work and we help you along, that's how this works.

3. ### WBahn Moderator

Mar 31, 2012
18,087
4,917
Do you know how to accept a single integer value from the keyboard and put it into a variable of type int?

Do you know how to loop through an array of ten integers?

If so, try your best to combine these two and show your best shot at it.

4. ### spinnaker AAC Fanatic!

Oct 29, 2009
5,076
1,176
You need to work on both your homework and your subject lines. Yours says nothing about your problem.

And your problem does not make any sense. Unless the human is going to input in descending order.

5. ### Cardinal Steel Lungs New Member

Oct 14, 2014
1
0
I'm assuming (yes I know the name of the game is assume nothing, but I'm a renegade Cardinal) that he wants to print the integers in descending order, and he forgot to elucidate that point.

So you need to accept user input into an array of type int, iterate through the array and implement the logic required to print in descending order... or something. Maybe.

Feb 12, 2015
10
0

File size:
184 bytes
Views:
18

Feb 12, 2015
10
0

File size:
184 bytes
Views:
10

Feb 12, 2015
10
0

File size:
184 bytes
Views:
12
9. ### DumboFixer Active Member

Feb 10, 2009
219
34
Ok, I've done that - now what do I do ?

10. ### ErnieM AAC Fanatic!

Apr 24, 2011
7,436
1,626
That is at least a start, good. It should compile as the for loop only has a single statement; generally you will have more than one statement so you would need { } brackets to enclose the loop. So what you did was fine it is preferable to add those brackets even if not completely necessary. That's just good practice (meaning it reduces errors).

So you have a loop to accept the 10 integers, so far so good. Now you need to sort the numbers. Have you researched how to sort things? You have your class book, notes, and Google to help you there. You may want to try looking up "bubble sort."

Some standard C/C++ libraries already have sort routines, but I would not advice using them for now. It is better if you learn how to write a simple routine like this as a learing tool.

Feb 12, 2015
10
0

12. ### PrincoPrince Thread Starter New Member

Feb 12, 2015
10
0
Please how do I sort the code.

Apr 11, 2010
2,905
878