anonymous
  • anonymous
Write a program that allows a user to input up to 20 integers. First ask the user how many numbers (num), up to 20, they wish to enter. Then prompt the user for num numbers, storing them in an array.
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
katieb
  • katieb
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
You're including the question of how many numbers inside the loop. Try taking this two lines outside the for: cout << "How many numbers will you be entering (up to 20): " <> num0; That way the program will loop only the "Enter a number" part, for the 0 -> num0 (specified input) part.
anonymous
  • anonymous
Yeah I just figured out myself LOL XD
anonymous
  • anonymous
Now I'm working on this part: Finally print the numbers in reverse, separated by a comma and a single space, on a single line.

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
Thanks again :D
anonymous
  • anonymous
I think I just have to create a loop counting down right?
anonymous
  • anonymous
You're welcome lol =) For that last part, in Java I would do: for(int i = array.length; i >= 0; i--){ System.out.print(array[i]+", "); }
anonymous
  • anonymous
Yep, just start at the end and go down to 0, and either store it in a String variable, or directly print it without jumping lines
anonymous
  • anonymous
Hmmm let me try to work it out.
anonymous
  • anonymous
Why did you write array[i]+?
anonymous
  • anonymous
It's Java, + is used to put together two strings [or a number and a string]. array[i] + " hello" would print: "21 hello" (assuming the number in array[i] was 21)
anonymous
  • anonymous
Hmm I'm wondering what to put into my cout function... it would be the array with the new numbers...
anonymous
  • anonymous
for(int i = num0; i>0; i--) { cout << "{" << myArray[num1] << "}" << endl; } I have this for num1 = inputted numbers of the array. Do I need a new array name?
anonymous
  • anonymous
You need to include the 0 in the array, so i >=0 You can keep the same array, just remember 'myArray[num1] doesn't make much sense, since num1 can take any value the user inputs, can be outside the range of indexes of your array, choose the variable your for is sweeping to put inside your array. In this case it's i. You should have something like for(int i = num0; i >= 0; i--) { cout << "{" << myArray[i] << "}" << endl; }
anonymous
  • anonymous
Hmmm for some reason, my program keeps crashing... lol I think there's something I'm messing up in the loop! I'll see if I figure it out and then I'll come back to you. Thanks a bunch for your help as always!!! :D
anonymous
  • anonymous
You're welcome :) good luck

Looking for something else?

Not the answer you are looking for? Search for more explanations.