i am supposed to come with a output
***
****
*****
******
*****
****
***
for entering 3 and 6 as input but i am having problems with my output it seems as if i have an infinite for loop some where can some 1 help me out thank you
With that method, there should not be any need for if() statements inside the loops.
1 2 3 4 5 6 7
void Triangle( int small, int large ) {
for( int i = small; i <= large; ++i )
std::cout << std::string( i, '*' ) << std::endl;
for( int i = large - 1; i >= small; --i )
std::cout << std::string( i, '*' ) << std::endl;
}
Now all you need to do is write a loop that outputs N asterisks followed by a newline
(to replace my std::string( i, '*' ), which constructs a string of i asterisks.)
I was thinking that my program was a bit over the top, and that it probably could be shortend but my mind went a blank!
To be fair though, I didn't even know your use of std::string was possible. Edit* Yes i have just checked the documentation before you tell me its there! :(