• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 277
  • Last Modified:

for loop

I have a function that accepts three ints
void outdata(int num1,int num2, int pline)
  for (int i=num1;i<num2;i++)//this is for printing the
    cout<<i;                //  range of numbers.
I need a for loop to print the pline which is the number
to printed out per line.
I am sure that there is a simply fix I am over looking the
easy solution again
any help would be great.
Thank you  

1 Solution
Like this?

void outdata( int num1, int num2, int pline )
  int curCount = 0;
  for( int i = num1; i < num2; i++ )
    cout << i;
    if( curCount == pline )
      cout << endl;  // new line
      curCount = 0;  // reset the count
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

7 new features that'll make your work life better

It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now