How do you do this
how many for loops do I need, basicaly I just need the formula rather than the whole answer.Code:* * * * * * * * * * * * * * * * * *
Code tags added by Hammer
How do you do this
how many for loops do I need, basicaly I just need the formula rather than the whole answer.Code:* * * * * * * * * * * * * * * * * *
Code tags added by Hammer
For 2 dimensional figures, most people would use two loops. One for the x-direction and one for the y-direction.
Whatever is the number of rows , that should be taken as your main FOR loop. And try to analyse the pattern of what is required.
See there are alternatively 4 and 3 stars. So set one boolean variable to do that thing.
>See there are alternatively 4 and 3 stars. So set one boolean variable to do that thing.
More easy would be to use the modulo-operator. At the even lines there are 3 stars, at the odd lines there are 4 stars.
>>how many for loops do I need,
None. Just printf() the output in the desired format directly. One line of code will do it. (oh, don't tell me, you have to use loops )
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
What a logic.>>>>how many for loops do I need,
None. Just printf() the output in the desired format directly. One line of code will do it. (oh, don't tell me, you have to use loops ),
You can do this with one loop, and the box size would be sizable (ie: you input the size). It's just a matter of providing the right conditions in the loop.
Quzah.
Hope is the first step on the road to disappointment.