Hi again all,
I am having some troubles making this program. Here is the assignment:
and here is my code:
Write a computer program that prints a triangle of digits. Your program must read two positive integers as follows:
the width of the triangle, and
the position of the triangle relative to the left margin (the amount to indent the triangle, in other words).
You can assume that the user will always enter non-zero positive integers.
The triangle is drawn upside-down using single digit integers. For example, a width 3 indent 3 triangle looks like this:
... and a width 13 triangle indent 0 triangle looks like this:
When the program is run it looks like this:
using namespace std;
int main ()
int width = 0;
int indent = 0;
int digit = 1;
cout<<"Enter the width of the triangle: ";
cout<<"Enter the position relative to the left margin (the indent): ";
for (int x = 0; x < width; x++)
for (int i = 0; i < indent; i++)
for (int w = 0; w < width; w++)
digit = 1;
I understand why it quits short but am unable to figure out a fix for the problem.
Enter the width of the triangle: 5
Enter the position relative to the left margin (the indent): 3
Anyone got some suggestions? Thank you!