Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 C++ Nested Loops
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
konrbear




PostPosted: 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;
}
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Mon Oct 27, 2014 1:06 am   Post subject: RE:C++ Nested Loops

It's not clear what your question is.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Hergz




PostPosted: 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
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: