nested loop problem

i have my very difficult problem :
here it is :

the output must be :

Enter number 5:
\\output......

1
12
123
1234
12345

here is my code :

#include <iostream>
#include <conio>

main()
{

int a,x,y;

cout<<"Enter number: ";
cin>>a;

if(a>3)
{
for(x=a;x>=1;x--)
{
for(y=1;y<=x;y++)
{
cout<<y;
}
cout<<"\n";
}
}


getch();
}

the problem is that
when i run my source code in c++.

the output is :

12345
1234
123
12
1

whats wrong with my code? ...... can some figure it out....
thanks.
try the following code

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
#include <iostream>
#include <conio.h>
using namespace std;

int main()
{

int a,x,y;

cout<<"Enter number: ";
cin>>a;

if(a>3)
{
for(x=1;x<=a;x++)
{
for(y=1;y<=x;y++)
{
cout<<y;
}
cout<<"\n";
}
}
return 0;
}
Topic archived. No new replies allowed.