Hey everyone,
I am new to this site, basically my problem is this: The user inputs an integer, and then the user inputs a character, the program is supposed to make a triangle out of the character, with the max width of the user inputed integer.
for example;
user inputs integer 5
user inputs character *
output:
*
**
***
****
*****
****
***
**
*
the following code that I have written only takes me about half way there and gets me to:
*
**
***
****
*****
#include "StdAfx.h"
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int num;
int rows;
char x;
do
{
cout << "Enter an integer" << endl;
cin >> num;
cout << "Enter symbol" << endl;
cin >> x;
for(rows=0;rows<num;rows++)
{
for (int axis=0; axis<=rows;axis++)
{
cout<<x;
}
for (int len=num;len>rows+1;len--)
cout<<" ";
cout<<endl;
}
cin.ignore();
cin.ignore();
} while(cin);
return 0;
}
Any help/response is much appreciated, thanks!