MY problem is .....
Given an input 'n' came from the user and display a pattern.
but my code is very long .... my code is only for 1-10 numbers i need to display any numbers that input of the users can u give me some short code or advice to make it easy or briefly...Thxxxxx
Ex. if n=6, display
Ex. output
6 5 4 3 2 1
6 5 4 3 2
6 5 4 3
6 5 4
6 5
6
#include<iostream.h>
#include<conio.h>
main()
{
int n1,i;
char c1;
textcolor(YELLOW);
a:
clrscr();
cout<<"Enter a number :";
cin>>n1;
for (i=n1;i>0;i--)
{
cout<<" "<<i;
}
cout<<endl<<" ";
for (i=n1;i>1;i--)
{
cout<<" "<<i;
}
cout<<endl<<" ";
for (i=n1;i>2;i--)
{
cout<<" "<<i;
}
cout<<endl<<" ";
for (i=n1;i>3;i--)
{
cout<<" "<<i;
}
cout<<endl<<" ";
for (i=n1;i>4;i--)
{
cout<<" "<<i;
}
cout<<endl<<" ";
for (i=n1;i>5;i--)
{
cout<<" "<<i;
}
cout<<endl<<" ";
for (i=n1;i>6;i--)
{
cout<<" "<<i;
}
cout<<endl<<" ";
for (i=n1;i>7;i--)
{
cout<<" "<<i;
}
cout<<endl<<" ";
for (i=n1;i>8;i--)
{
cout<<" "<<i;
}
cout<<endl<<" ";
for (i=n1;i>9;i--)
{
cout<<" "<<i;
}
{
cout<<""<<endl<<""<<endl;
cout<<"Do you want to try another number or EXIT...?"<<endl;
b:
cout<<"Press 'y' if you want to try another number and 'n' to exit:";
cin>>c1;
if ( c1=='y' || c1== 'Y')
goto a;
else if (c1=='n' || c1=='N')
cout<<endl<<"Press Any Key to EXIT";
else
{
cout<<"Invalid input, Choose again"<<endl;
goto b;
}
}
getch();
}