So, when dealing with small loops like this it usually helps to think about every step you want your program to make:
First: you want only one number to be outputted, and you want this number to be a zero:
so starting k = 0 is a good start, because you want to output 0 in the begining each time, but you want to change how many numbers it outputs each time.
so in your inner loop, you want the number that k is less then "<" to change each time.
once everything is said and done, you should have something like this:
1 2 3 4 5 6 7 8 9
|
for ( int i = 0; i <=5; i++ )
{
for ( int k = 0; k <= i; k++ )
{
cout << k;
}
cout << endl;
}
|
the "magic number" 2 that jlb was speaking of, is the reason why you are only getting 2 numbers on each of your lines.
and I'm not sure why you were multiplying, but it makes things a lot easier not to do that.
Good Luck