// Function getUserInput obtains an integer input value from the user.
// This function performs no error checking of user input.
int getUserInput ( )
char goAgain;
{
do
{
int N ;
cout << endl << "Please enter a positive, odd integer value: " ;
cin >> N ;
cout << endl ;
return N ;
} // end getUserInput function
// Function printDiamond prints a diamond comprised of N rows of asterisks.
// This function assumes that N is a positive, odd integer.
void printDiamond (int N)
{
for (int i = 1; i <= N; i += 2)
{
for (int j = 0; j < (N - i) / 2; j++)
{
cout << ' ';
}
int main ( )
{
printDiamond ( getUserInput() ) ;
cout << "Go again (y for yes, n for no): " ;
cin >> goAgain ;
}
while ( (goAgain == 'y') || (goAgain == 'Y') )
return 0;
} // end main function