How do I terminate infinite loop for printing ascii clown jgs?

Hello,

I have the following code so far, but it goes into an infinite loop when executed. Could someone please review the code? I'm not certain how to get the conditions in there to only print 2 to 8 clowns. Any suggestions?

/* Solo4.cpp. This program prompts the user to enter an integer, N,
between the values 2 to 8, then prints N number of clowns that
end with a base
*/

#include<iostream>

using namespace std;

void PrintInfo();
//Prints information about the program.
void PrintDirections() ;
//Prints directions for the user on how to use the program.
void MakeOneClown() ;
//Prompts user to enter a number, N, between 2 to 8, then prints
//N of clowns.
void MakeBase() ;
//Prints a base at the end of the stack of clowns.

int main()

{
int N; // number of clowns

PrintInfo() ;
PrintDirections () ;

int i;

for (int i = 1; i < N; i++)
{
MakeOneClown () ;
MakeBase() ;
}


}



/* ************************************************ */
/* PRINT INFORMATION */
/* ************************************************ */

/* Prints information about the program */

void PrintInfo()
{
cout << "This program uses ASCII art to make a stack of carnival clowns.";
cout << endl;
cout << "You may request a stack containing between 2 and 8 clowns.";
cout << endl;
}

/* ************************************************ */
/* PRINT DIRECTIONS */
/* ************************************************ */

/* Prints directions for using the program */

void PrintDirections()
{
int N;

cout << "This program uses ASCII art to make a stack of" << endl;
cout << "carnival clowns. You may request a stack containing"<< endl;
cout << "between 2 and 8 clowns." << endl;
cout << endl;
cout << "How many clowns would you like to see? ==>" <<endl;
cin >> N ;
}

/* ************************************************ */
/* MakeOneClown */
/* ************************************************ */

/* Prompt the user to enter the amount, N, of clowns to be
printed then return N clowns.*/

void MakeOneClown()
{
cout <<" 0_ \n";
cout <<" \\`.___\n" ;
cout <<" \\ \\ /__>0\n";
cout <<" /\\/|/ /\n";
cout <<" /\\/`,`'--.\n";
cout <<" //(_____________)_\\ \n";
cout <<" |/ //.-..-.\\\\ \\ \\ \n";
cout <<" 0 // :@ __ @: \\\\ \\/ \n";
cout <<" ( o ^(__)^ o) 0\n";
cout <<" \\ \\_______/ /\n";
cout <<" jgs \\`.______.\\`\n";

}

/* ************************************************ */
/* MakeBase */
/* ************************************************ */

/* Prints base at the end of the stack of clowns */

void MakeBase()

{
cout <<" ||||||||||||\n";
cout <<" |||||||||||||||||||\n";
cout <<" ||||||||||||||||||||||\n";
cout <<" ||||||||||||||||||||||||||\n";

}






Thank you in advance,
Neema
N is not initialized to any value in main(). Instead of declaring it in PrintDirections(), pass it be reference.
The N in main() is NOT the N in PrintDirections().
Thank you for the quick reply! i'm not certain on what part of my code is falling short still. I took out N from printdirections and put it in int main(). It stopped the loop but now it won't print anything after an N is entered. This is what I have:

int main()

{
int N; // number of clowns
cout << endl ;
PrintInfo() ;
PrintDirections () ;

cout << "how many clowns would you like to see? ==>" << endl;
cin >> N ;
return N ;

int i;

for (int i=1; i < N; i++)
{
MakeOneClown();
MakeBase() ;
}


}



/* ************************************************ */
/* PRINT INFORMATION */
/* ************************************************ */

/* Prints information about the program */

void PrintInfo()
{
cout << "This program uses ASCII art to make a stack of carnival clowns.";
cout << endl;
cout << "You may request a stack containing between 2 and 8 clowns.";
cout << endl;
}

/* ************************************************ */
/* PRINT DIRECTIONS */
/* ************************************************ */

/* Prints directions for using the program */

void PrintDirections()
{
cout << "This program uses ASCII art to make a stack of" << endl;
cout << "carnival clowns. You may request a stack containing" << endl;
cout << "between 2 and 8 clowns." << endl;
cout << endl;
}

/* ************************************************ */
/* MakeOneClown */
/* ************************************************ */

/* Prompt the user to enter the amount, N, of clowns to be
printed then return N clowns.*/

void MakeOneClown()
{
cout <<" 0_ \n";
cout <<" \\`.___\n" ;
cout <<" \\ \\ /__>0\n";
cout <<" /\\/|/ /\n";
cout <<" /\\/`,`'--.\n";
cout <<" //(_____________)_\\ \n";
cout <<" |/ //.-..-.\\\\ \\ \\ \n";
cout <<" 0 // :@ __ @: \\\\ \\/ \n";
cout <<" ( o ^(__)^ o) 0\n";
cout <<" \\ \\_______/ /\n";
cout <<" jgs \\`.______.\\`\n";

}

/* ************************************************ */
/* MakeBase */
/* ************************************************ */

/* Prints base at the end of the stack of clowns */

void MakeBase()

{
cout <<" ||||||||||||\n";
cout <<" |||||||||||||||||||\n";
cout <<" ||||||||||||||||||||||\n";
cout <<" ||||||||||||||||||||||||||\n";

}


Thanks again,
Neema
That's because you are returning from main() after getting N. After you return from main() the program is over.
Topic archived. No new replies allowed.