Pyramid Code for Beginners

I wrote a code for the following output:

1
21
321
4321
54321



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include<iostream>
using namespace std;
void main ()
{
    int c,rows,i,i2,r=0;

	cout<<"1"<<endl;

	for (rows=1;rows<=4;rows++)
	{
		 i=1;
		 i2=1;

		for (c=1;c<=rows;c++)
		{ 
			i = (i*10) + ++i2;
		}


		for (;i != 0;)
	
		{
			r= r * 10;
			r= r + i % 10;
			i= i/10;
		}

		cout<<r<<endl;
	}
}



I'm a C++ beginner and I'm sure they're much simpler ways of coding for this output but I really can't figure out why this code isn't running. Anyone who can tell me where I've gone wrong?
Is your program:
1) Not compiles
    * Is other code compiles correctly, i. e. is your compiler configured properly?
    * If it is, give us error message and corresponding code part.
2) Not running
    * Are you sure that it is not a problem with automatically closing console?
    * How do you run it?
    * Is there any error messages?
3) Gives an error when run
    * Is it system error message or error reported in console?
    * Give us error message and input which leads to error.
4) Not giving correct results
    * Tell what you entered, what you expected, and what you got.
    * Are you sure that results you expected are correct?
Topic archived. No new replies allowed.