Computer Science Canada

C++ Nested Loops

Author:  konrbear [ Sun Oct 26, 2014 6:20 pm ]
Post subject:  C++ Nested Loops

I need the program output 1- 100 like below.
1 2 3 4 5 6 7 8 9 10
11 12 13 14 15...

#include <iostream.h>
#include <conio.h>

main ()
{
int i, j, Num;

for(i = 0; i <=90; i++)
{
for (j=1; j <=9; j++)
Num = i + j;
cout << Num << " ";

}

return 0;
}

Author:  Tony [ Mon Oct 27, 2014 1:06 am ]
Post subject:  RE:C++ Nested Loops

It's not clear what your question is.

Author:  Hergz [ Mon Oct 27, 2014 12:21 pm ]
Post subject:  Re: C++ Nested Loops

Like Tony said your question is unclear but I'll try to help by assuming you need a program to write 1-100 with 10 numbers per line, with nested loops?
c++:

int numberCount, lineCount;

numberCount = 1;
lineCount = 1;

while (numberCount <= 100){
   while(lineCount <= 10){
      cout << numberCount << " ";
      numberCount++;
      lineCount++;
   }
   cout << endl;
   lineCount = 1;
}


Hopefully that helps


: