Enter those numbers into an Array, and then Show them.
Sample Run:
How many numbers would you like to enter? 8
Enter number 1: 5
Enter number 2: 3
Enter number 3: 10
Enter number 4: 15
Enter number 5: 25
Enter number 6: 21
Enter number 7: 99
Enter number 8: 16
The numbers you entered are: 5, 3, 10, 15, 25, 21, 99, 16
Here's what I have so far. How would I make it continue the loop based on how many numbers the user entered? Mine goes to whatever I put for "i" in my for loop?
Hi,
Well, best place is at the point where you realise this isn't a homework site and showing us where you are having problems etc with work you have put in. Cut and paste the assignment doesn't count.
Everybody here is glad to help when you get off the starting blocks :)
#include <iostream>
#include <stdlib.h>
usingnamespace std;
int main ()
{
int i, count = 0;
int numArray[4000];
cout << "How many numbers would you like to enter? : ";
cin >> count;
for (i = 0; i < count; i++)
{
cout << "Enter number " << i+1 << " : ";
cin >> numArray[i];
}
cout << "The numbers you entered: ";
for (i=0; i< count; i++)
{
cout << numArray[i];
if (i < count - 1)
cout << ", ";
}
cout << endl;
system("pause");
return 0;
}
#include <iostream>
#include <stdlib.h>
usingnamespace std;
int main ()
{
int i;
int numArray[4000];
int count = 0;
int numberAmount;
cout << "How many numbers would you like to enter? "; // not sure how to do this
cin >> numberAmount;
for (i = 0; i < 5; i++)
{
cout << "Enter number " << i+1 << " : ";
cin >> numArray[i];
}
cout << "the numbers you entered: ";
for (i=0; i< 5; i++)
{
cout << numArray[i] ;
if (i<4)
cout << ",";
}
cout << endl;
system ("pause");
return 0;
}