Okay, so I've been at this for hours, editing, deleting, remaking my code and I can get one array easily, but adding the second array is hard and driving me nuts.
I know it's not much, I'm only a beginner.
The problem is:
Write a program that will fill arrays with values read from the user. If the number read is greater than 0, it will be stored in arrayA. If the number read is less than 0, it will stored in arrayB.
Both arrays will be a partially filled arrays and the user will be asked to enter a number only he/she wishes to continue.
However, even if the user wants to enter another number, the program should not read more than 10 numbers.
The program will then print the content of the arrays to screen.
I have this as of right now, which is one array;
include <iostream>
using namespace std; int main() { char choice; int num[10], index = 0;
do
{
cout << "Please enter a number" << endl;
cin >> num[index];
index++;
cout << "Press Y if you'd like to continue" << endl;
cin >> choice;
} while ((choice == 'Y') || (choice == 'y') && (index < 10));
for (int i = 0; i < index; i++)
{
cout << num[i] << " ";
Since you're not showing any code that has multiple arrays, what exactly is your question?
As a hint, for this assignment you will need two arrays and a "temporary" variable to accept user input. Then you will need to decide which array you need to put that input into, based on if it is either greater than or less than zero.
By the way what happens if the user enters a value of zero?
a little more clarification...
you need 2 arrays, say int positives[10] and int negatives[10]
and 2 indices for these: int pdx = 0; int ndx = 0;
then do a lot like what you did, ask for a number, if it is > 0 then positives[pdx++] = number, else if negative negatives[ndx++] = number. Pdx and ndx will happily tell you how many locations in each were used when printing them back out.