Help cant figure this out

ErnieM

Joined Apr 24, 2011
8,377
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.
 

WBahn

Joined Mar 31, 2012
30,062
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.
 

spinnaker

Joined Oct 29, 2009
7,830
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.
 
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.
 

ErnieM

Joined Apr 24, 2011
8,377
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.
 

WBahn

Joined Mar 31, 2012
30,062
How would you do it by hand?

If I give you the numbers: 6, 3, 19, 6, 23, 42, 2

And said that I needed you to tell me how to sort them. What directions would you give me? Put it as a list of simple steps that a 7 year old could follow.
 
Top