Friday 10 October 2014

c++ print left triangle upper portion

void main()
{
int size=3;
        cout<<"please enter the size of triangle to print";
cin>>size;
int margin_space;
int row=1;
while(row<=size)
{
margin_space = size - row;
int col = 0;
while(col<margin_space)
{
cout<<" ";
col = col+1;
}
int starics = 1;
while(starics<=row)
{
cout<<"X";
starics++;
}
cout<<endl;
row++;
}
}


output:-