#include <iostream.h>
#include <conio.h>
int main()
{
int i, k, n;
wronginput:
cout << "\nEnter The Number of lines {1..10}\n";
cin>> n;
if(n < 1 || n >10)
{
cout<<"\nPlease Enter The Number of lines B/W {1..10}\n";
goto wronginput;
}
for (i=1;i<=n;i++)
{
for(k = n-i; k>0;k--)
cout<<(" ");
for(k=1;k<2*i;k++)
cout<<i;
cout<<endl;
}
cout<<endl<<"Press any key to quit";
system("PAUSE");
return 0;
}
A few problems with your code:
1) The correct header is #include <iostream>
2) You need usingnamespace std;
3) goto should be avoided. Use a do {} while (); loop.
4) You need an additional loop for the right side of the triangle.