-
Newbie help
Hello. I was given the task to create a dimond. For example, if the user imputs 5, the output would be:
$
$$$
$$$$$
$$$
$
get it? While it was easy to get this part:
$
$$$
$$$$$
I have having problems with the bottom part. I am only allowed to use 2 loops(1 nested loop). Any ideas?
Please be gentle, I am a newbie. :)
-
Use a for loop and increment your index forward. Then use another that indexes it backwards.
-
I'm not sure I follow. Here is what I have.
<code> for ( int i = 3; i<=dn; i+=2)
{
for (int j=1; j<=i; j++)
{
cout<<dc;
}
cout<<endl;
}</code>
No somewhere in those loops I must make it print backwards. I figure I gotta set up an if clause once it reaches the max number, but I don't know what to do with it.
-
Read Cshot's answer again. You need a second for loop, initialize it to 5, then decrement it instead of increment. You don't need to nest these loops.
Also, nice try on the code tags, at least you tried, but they should be straight brackets , not angle brackets. Or use the php button.
-
you can use output flags to do that read about the flags becouse i saw this kind of example in a book in output flags section
-
Quote:
Originally posted by salvelinus
Read Cshot's answer again. You need a second for loop, initialize it to 5, then decrement it instead of increment. You don't need to nest these loops.
Also, nice try on the code tags, at least you tried, but they should be straight brackets , not angle brackets. Or use the php button.
Sorry about the brackets. Anyway, I NEED to use nested loops. It is part of the project.