If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: printing 2 arrays with 10 numbers per line

hey guys i got 2 arrays, how would i print 10 numbers per line, so that would be 5 numbers from each array.

This is basically the same question as your other thread you started.

How do you print two items on a line? Forget about arrays for the moment -- I have two int variables, how do you print both of them on the same line?

Code:

#include <iostream>
int main()
{
int i = 1;
int j = 2;
//...
}

Using cout, how do you print both the value of i and j on the same line? OK, if you can do that, then that is the first step.

So now in a loop, how do you print array1[x] and array2[x] on the same line? OK, if you can do that, what does the "x" denote? Doesn't that look like an index that will go from 0 to 40 (or to be exact, 39)? What construct uses an index? Isn't it the for-loop construct?

Now how do you print a line, regardless of what's on that line, and then place the output cursor on the next line? Isn't that just "\n" or endl? Now combine all of that information.

Re: printing 2 arrays with 10 numbers per line

How do you print two items on a line? Forget about arrays for the moment -- I have two int variables, how do you print both of them on the same line?

Code:

#include <iostream>
int main()
{
int i = 1;
int j = 2;
//...
}

Using cout, how do you print both the value of i and j on the same line? OK, if you can do that, then that is the first step.

So now in a loop, how do you print array1[x] and array2[x] on the same line? OK, if you can do that, what does the "x" denote? Doesn't that look like an index that will go from 0 to 40 (or to be exact, 39)? What construct uses an index? Isn't it the for-loop construct?

Now how do you print a line, regardless of what's on that line, and then place the output cursor on the next line? Isn't that just "\n" or endl? Now combine all of that information.

This is how you break down a problem.

Regards,

Paul McKenzie

they are different because in this one i know the how many elements each array has, in the other thread. i dont know hom many elements each array has but just maximum elements it can hold.

"The speed of non working code is irrelevant"... Of course that is just my opinion, I could be wrong.

"Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan 'press on' has solved and always will solve the problems of the human race."...Calvin Coolidge 30th President of the USA.