Hello daniweb people! I'm having a few issues with this triangle program. We're supposed to make a few different triangle shapes, including the two i have in this. The first triangle works, but the second triangle displays xxxxxxxxxxxxxxx times infinity. Any ideas on what i'm doing wrong? And another question, how would I get started with part of this program to also make a diamond shape given a certain Row size input? thanks!
#include <iostream>
#include <math.h>
#include <string.h>
using namespace std;
int main()
{
// make triangle
// X
// XX
// XXX
// XXXX
// XXXXX
// XXXXXX
int rowSize;
cout << "Please enter the number of rows between 3 and 6 for a triangle: ";
cin >> rowSize;
for (int r=0;r<rowSize;r++)
{
for(int c=0;c<r+1;c++)
{
cout << "*";
}
cout << endl;
}
{
// Make triangle shaped different like so:
// ******
// *****
// ****
// ***
// **
// *
int rowSize;
cout << "Please enter another row size for a different triangle: ";
cin >> rowSize;
for (int r=0;r<rowSize;r++)
{
for (int c=0;c<r-1;c--)
{
cout << "*";
}
cout << endl;
}
system("pause");
return 0;
}
}