I need help wirting a program that will count from 100 to 150 but in six lines, i have it were it contiues to count on one line, i dont know how to six lines using one single loop. i have this so far: Can some one help! thanks

for (int num=100;num <= 150;num+=2)
cout << num << " " ;


EX. 100 102 104 106 108 110
112 114 116 118 120 122
124 126 128 130 132 134
136 138 140 142 144 146
148 150

A quick question...can it be random numbers between 100 & 150...or do they have to be incremented by 2 each time?

It has to be in this order starting at 100 and ending at 150. I just cant seem to get it to drop at 110,122,134,136 to the next line. hope this helps i can only use one for loop

it has to look like this
100 102 104 106 108 110
112 114 116 118 120 122
124 126 128 130 132 134
136 138 140 142 144 146
148 150

oh yea it has to count be incremented by 2's

will you get the numbers from user input? Will they be stored into an array from an infile? where will you get the numbers from?

I dont get any input from the user i have to generate these numbers

Count each number you output. After every 6th number, output a newline (\n)

Use the % operator.

thats what i was thinking, you know using the %, but i dont know how to put it together. Im just a newbie to c++. is it something like this

for (int num=100;num<=150;num+=2)
if (num%6=0)
cout << num << " ";

were do i put the endl;

thats what i was thinking, you know using the %, but i dont know how to put it together. Im just a newbie to c++. is it something like this

for (int num=100;num<=150;num+=2)
if (num%6=0)
cout << num << " ";

were do i put the endl;

Close. Remember, 6 doesn't evenly divide 100: if (((num - 100) % 6) == 0) cout << endl; Hope this helps.

Thanks Duoas, you sent me in the right direction, here was the program that worked, once again thanks!!

for (int num5=100;num5<=150;num5+=2)
          { 
     if (((num5 - 100) % 12) == 0) cout << endl;
      cout << num5 << " ";
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.