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,387
    1,605
    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
    17,743
    4,795
    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
    4,884
    1,005
    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.
     
  6. PrincoPrince

    Thread Starter New Member

    Feb 12, 2015
    10
    0
     
  7. PrincoPrince

    Thread Starter New Member

    Feb 12, 2015
    10
    0
     
  8. PrincoPrince

    Thread Starter New Member

    Feb 12, 2015
    10
    0
     
  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,387
    1,605
    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.
     
  11. PrincoPrince

    Thread Starter New Member

    Feb 12, 2015
    10
    0
     
  12. PrincoPrince

    Thread Starter New Member

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

    AAC Fanatic!

    Apr 11, 2010
    2,804
    833
    Google "sort algorithms"
     
  14. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,795
    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.
     
Loading...