let me guess your using a book by lawrenceville press
Code:
#include <iostream.h>
//------------------------------------------------------------------------------
void Spaces(int spaces)
/* Set leading spaces before the '*' */
{
for(int count=0; count<=spaces; count++)
{
cout<<" ";
}
}
//------------------------------------------------------------------------------
void DrawBar(int sizeofrow,int spaces)
/* Display a bar of '*' of a set increasing lenght */
{
Spaces(spaces);
for(int count=0; count<sizeofrow; count++)
{
cout<<"*";
}
cout<<endl;
}
//------------------------------------------------------------------------------
void Isotriangle(int columns)
/* Build the triangle and set size of bars */
{
int count=0;
int sizeofrow=1;
int stospaces;
stospaces=columns;
while(count!=columns)
{
count++;
if (count>1)
{
sizeofrow=sizeofrow+2;
}
DrawBar(sizeofrow, stospaces);
stospaces--;
}
}
//------------------------------------------------------------------------------
int main()
{
int columns;
cout<<"Enter the number of rows you want for your triangle: ";
cin>>columns;
Isotriangle(columns);
cout<<endl;
return (0);
}