i know everyone has probably gone over this one a hundred times, but i'm trying to draw a triangle using asterisk, but i also have to be able to declare the amount of triangles input by the users. Here is my code so far, it will print one triangle without the initial for loop, can anyone tell me where i'm going wrong?
#include <iostream>
using namespace std;
int main()
{
char a = '*';
int b;
int c;
int d;
int num;
int i;
cout << "Please enter the number of stars you would like to print: " <<endl;
cin >> num;
for (i=1;i <=num; i++)
{
cout << "Please enter the width of the last row.." << endl;
cin >> b;
if (b < 5 || b > 21)
{
cout << b << " is invalid please enter a number between 5 and 21" << endl;
cin >> b;
}
for (c=1; c<=b; c++)
{
for (d=1; d<=c; d++) cout << a;