Solved

for loop

Posted on 1998-09-19
1
217 Views
Last Modified: 2010-04-01
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  
 

 
0
Comment
Question by:strmtrpr
1 Comment
 

Accepted Solution

by:
dave81 earned 50 total points
ID: 1173178
Like this?

void outdata( int num1, int num2, int pline )
{
  int curCount = 0;
  for( int i = num1; i < num2; i++ )
  {
    cout << i;
    curCount++;
    if( curCount == pline )
    {
      cout << endl;  // new line
      curCount = 0;  // reset the count
    }
  }
}
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now