Skip to main content
0 online
theremin Jul 26, 2006

Ok. That's done with. Here's 2 others I need help with that I'm posting in the midst of trying to figure it out in the meantime. #1 an array called "alpha" with 50 components - type is double...

iwz Jul 26, 2006

what are you having trouble with on #1?

theremin thereminOG 2002 ·

The biggest thing I need help with on is how to print out 10 elements per line

yay yayOG 2004 ·

its just an array with 50 elements printed out in 10's

theremin thereminOG 2002 ·

10 elements per line need to be outputted. But, How do I do that?

I thought maybe a nested for loop like this one

for (index = 0; index < 50; index++)
for (item = 0; item < 10; item++)
cout << alpha[index] << " " << endl;

But, is that how?

Probably nothing like that, right?

I doubt myself.

yay yayOG 2004 ·

There ya go. But the first loop should not be increased by 1, but 10, otherwise you'll have 40 more sets of 10 printing out then expected

D
dgiaimoOG 2003 ·

Not quite. What you want is more like:

for (i = 0; i < 5; i++)
{

for (j = 0; j < 10; j++)
{
cout << alpha[10*i + j] << " ";
}

cout << endl;
}

Welcome Back to eZabel

It's been a while. Here's what's new.

eZabel Lore

A complete history of our community — stats, Hall of Fame, legendary threads, and more.

View the Lore →

Everything Preserved

All 225,969 pieces of content from 2000–2014 are here — forums, messages, journals, photos, polls, and events.

💎

Gems

Spot something you love — a legendary comment, a classic thread, a great photo? Log in and click the diamond icon to mark it as a Gem. Add a note about why it's special. The best stuff surfaces on the Gems page.