SOURCE FILE: starField.cpp
/*
With this program, the user can make a field of stars,
like the USA flag, except the user can ask for as many
rows as desired. (The USA flag has nine rows of alternating
lengths of 6 stars and 5 stars.)
*/
#include <iostream>
using namespace std ;
int GetRows () ;
/* gets the number of rows of stars that the user wants */
void MakeField (int rows_Arg) ;
/* make a field of stars with the specified number
of rows */
int main()
{
int number_of_rows ;
number_of_rows = GetRows() ;
MakeField (number_of_rows) ;
return 0;
}
int GetRows ()
{
int num_Rows ;
cout << "How many rows do you want in your field of stars? " ;
cin >> num_Rows ;
return num_Rows ;
}
void MakeField (int rows_Param)
{
int rowNum ;
cout << endl ; /* format -- make a blank line first */
for (rowNum=1; rowNum <= rows_Param; rowNum++)
{
if (rowNum %2 == 1) /* if it is an odd-numbered row ... */
{
/* Make a long row of six stars */
cout << "* * * * * *\n" ;
}
else
{
/* Make an indented short row of five stars */
cout << " * * * * *\n" ;
}
}
cout << endl ; /* format -- make a blank line last */
}