using for loops

cue any1 plyz help me out with writing a program that displays this
1*****
12****
123***
1234**
12345*
123456
using the for loop
for (int i = 0; i < 1; ++i) {
printf("1*****\n12****\n123***\n1234**\n12345*\n123456\n");
}
I assume you are a student. You should attempt problems yourself before asking for help. Rather than asking us to do it for you why not provide us with some example code and ask us what is wrong with it. Trying is better than not trying at all.

Here is the code anyway:

1
2
3
4
5
6
7
8
9
10
11
12
13
 int totalOutputs = 6;
 for (int b = 1; b <= totalOutputs; b++)
 {

  for (int i = 1; i <= totalOutputs; i++)
  {
     if (i > b)
        cout << "*";
        else
            cout << i;
  }
    cout << endl;
 }

Last edited on
Topic archived. No new replies allowed.