Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

for loop

Posted on 1998-09-19
1
Medium Priority
?
273 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
dave81 earned 100 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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 how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

609 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