Purpose of this blog is to make programming easy , weak programmers may get help from my blog i tried my best to post some of my codes in form of easiest approach, I think this blog is perfect c++ guide in form of online blog. please consult my all codes and suggest all of it with your class mates. Share experiences & knowledge with your juniors. Make yourself habitual to write different programs for 2 hours a day daily.
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++;
}
{
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:-
Subscribe to:
Posts (Atom)