Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOW DO YOU GET A PROGRAM TO RUN A FEW TIMES-ITERATIONS?

Status
Not open for further replies.

ankoump

Programmer
May 29, 2002
11
DE
I am currently writing code to run a model which takes particular dimensions and then produces results.For each run though there is a variable that changes randomly so i would like the program to run like a hundred times without me having to change the dimensions. Please can anyone help?
 
Heard of a for loop, or a while loop? Or maybe you want recursion?

Code:
for ( int i = 0; i < 100; i++ )
{
   // stuff
}

int i = 0;
while ( i < 100 )
{
   // stuff
}

int i = 0;
do
{
   // stuff
} while ( i < 100 )


void my_function( int p )
{
   // stuff

   if ( p > 0 ) 
        my_function( p - 1 );
}

int main()
{
    my_function( 100 );
    return 0;
}
dl_harmon@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top