#include <iostream>
usingnamespace std;
void printStars(int blanks, int starsInLine);
int main()
{
//Decleration of Variables
int noOfLines;
int counter;
int noOfdots;
//Prompting The User For Input
cout << "Enter the number of starred lines the triangle should have: " ;
//Storing User Input
cin >> noOfLines;
while (noOfLines < 0 || noOfLines > 20)
{
cout <<"The number of lines should be between 1 and 20"<< endl;
cout << "Enter the number of starred lines the triangle should have: " ;
cin >> noOfLines;
}
noOfdots = 30;
for ( counter=1 ; counter <=noOfLines; counter-- )
{
printStars(noOfdots, counter);
noOfdots--;
}
return 0;
}
void printStars(int dots, int starsInLine)
{
int count;
for (count = 1; count <= dots; count--) //Prints Number Of . Before Stars In A Line
cout<<'.';
for(count = 1; count <= starsInLine; count ++) //Prints Number Of Stars With Blanks Between
cout << " *";
cout << endl;
}
i also had the problem that i got unlimited - chars, because you dont give your variables a value, so dots and starsinlines gets a random bit pattern i think.
So i wanted to try to solve the problem and finally got the solution, a bit different than yours.
Do anybody knows if i these 4 for loops are nessesary? :)