This is a homework question I got for my programming course at school, and I'm kind of lost, so please help. Here is the question:
Write an application program that prints a diamond of asterisks (*) on the screen. The number of lines in the diamond is given by the user. As an example, if the user requested a diamond with 7 lines, the following would be displayed.
Here is what I have so far:
{
int nlines;
int nsp;
cout << "enter the number of lines (must be more then one)" << endl;
cin >> nlines;
while((nlines)<=0)
{
cout << "enter the number of lines (must be more then one)" << endl;
cin >> nlines;
}
nsp=(nlines - 1)/2;
for(int currspace = 1; currspace <= nsp; currspace++)
{
cout << " ";
}
cout << "*" << endl;
for( int currentline = 0; currentline < nlines; currentline++)
{
for( int currentaster = 0; currentaster <= currentline; currentaster++)
cout << "*";
cout << endl;
}
return 0;
See Question&Answers more detail:os