By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,321 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

output 6 values per line

P: n/a
How do I make my results from my program to show 6 values each line?

Expand|Select|Wrap|Line Numbers
  1. int main() {
  2.   int counter;
  3.  
  4.   counter = 100;
  5.   while (counter <= 150) {
  6.     cout << counter << endl;
  7.     counter = counter + 2;
  8.    }
  9.  
  10.   return 0
  11.   }
Oct 29 '10 #1
Share this Question
Share on Google+
1 Reply


Meetee
Expert Mod 100+
P: 931
I kind of understood your question but didn't understand your code. What I get is, you want to print like following in output:

1 2 3 4 5 6
7 8 9 10 11 12
.....
.....
and so on till 150.

If I am correct then you will have to put a loop which checks whether 6 values have been entered in each line or not. And then endl to print next line.
Oct 29 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.