Got Homework?
Connect with other students for help. It's a free community.
Here's the question you clicked on:
 0 viewing
mugwump101
Group Title
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.
 2 years ago
 2 years ago
mugwump101 Group Title
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.
 2 years ago
 2 years ago

This Question is Closed

Narsat Group TitleBest ResponseYou've already chosen the best response.2
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): " <<endl; cin >> num0; That way the program will loop only the "Enter a number" part, for the 0 > num0 (specified input) part.
 2 years ago

mugwump101 Group TitleBest ResponseYou've already chosen the best response.0
Yeah I just figured out myself LOL XD
 2 years ago

mugwump101 Group TitleBest ResponseYou've already chosen the best response.0
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.
 2 years ago

mugwump101 Group TitleBest ResponseYou've already chosen the best response.0
Thanks again :D
 2 years ago

mugwump101 Group TitleBest ResponseYou've already chosen the best response.0
I think I just have to create a loop counting down right?
 2 years ago

Narsat Group TitleBest ResponseYou've already chosen the best response.2
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]+", "); }
 2 years ago

Narsat Group TitleBest ResponseYou've already chosen the best response.2
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
 2 years ago

mugwump101 Group TitleBest ResponseYou've already chosen the best response.0
Hmmm let me try to work it out.
 2 years ago

mugwump101 Group TitleBest ResponseYou've already chosen the best response.0
Why did you write array[i]+?
 2 years ago

Narsat Group TitleBest ResponseYou've already chosen the best response.2
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)
 2 years ago

mugwump101 Group TitleBest ResponseYou've already chosen the best response.0
Hmm I'm wondering what to put into my cout function... it would be the array with the new numbers...
 2 years ago

mugwump101 Group TitleBest ResponseYou've already chosen the best response.0
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?
 2 years ago

Narsat Group TitleBest ResponseYou've already chosen the best response.2
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; }
 2 years ago

mugwump101 Group TitleBest ResponseYou've already chosen the best response.0
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
 2 years ago

Narsat Group TitleBest ResponseYou've already chosen the best response.2
You're welcome :) good luck
 2 years ago
See more questions >>>
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.