1. ## For Loops

This probably is a stupid question hey we all got to start programming somewhere.

I got to use for loops to generate two patterns as follows.
*****
****
***
**
*

and

*
***
*****
*******
*****
***
*

Any Ideas.

2. well
Code:
```for(i = 0; i < 10; ++i)
{
}```
is the same as
Code:
```i = 0;
while(i < 10)
{
++i;
}```
write some code if u haven't already and we'll help u out from there.

3. Try expirmenting with nested for loops.

For instance there are five lines to suggestion which implies a loop counting to five. Second there is an inner loop which print a number of stars based on the current line.

Code:
```numberofstars = maxstars;  // maxstars=5
for (int lines=0; lines<5;++lines)
{
while (numberofstar>0)
{
cout << '*';
numberofstar =numberofstars-1;
}
maxstars--;  // decrement by 1
numberstars=maxstars;
}```

4. ## clueless

I've absolutley no idea how to write a for loop. Does this website explain them well. I've written while loops if that is any help.

5. >I've absolutley no idea how to write a for loop.
I had problems with for loops when I started. It helps to build a for loop from the equivalent while loop. You construct it like so:
Code:
```/* Start with a while loop */
i = 0;
while ( i < 10 ) {
i++;
}

/* Put semicolons around the condition */
i = 0;
while ( ; i < 10 ; ) {
i++;
}

/* Put the initialization of the condition variable before the condition */
while ( i = 0 ; i < 10 ; ) {
i++;
}

/* Put the increment of the condition variable after the condition */
while ( i = 0 ; i < 10 ; i++ ) {
}

/* Change the keyword while to for */
for ( i = 0 ; i < 10 ; i++ ) {
}```
And you're done! Just remember that only the first and last steps of this process result in valid C code.

6. why doesn't this code work?

Code:
```// starts declining

# include <stdio.h>

int main()

{ int stars;

for(stars=5; stars>=1;stars--) // also for stars in range(6,0-1)
printf("*\n"*stars);

system("pause");

return 0;

}```

7. ## Re: clueless

Originally posted by apoc632
I've absolutley no idea how to write a for loop. Does this website explain them well. I've written while loops if that is any help.

LEARN FOR / WHILE LOOPS HERE

8. >why doesn't this code work?
Because it has syntax errors and undefined behavior. If you clean it up so that it works, you get this:
Code:
```// starts declining
# include <stdio.h>

int main()
{
int stars;

for(stars=5; stars>=1;stars--) // also for stars in range(6,0-1)
printf("*\n");

return 0;
}```

9. Originally posted by Prelude
[B]>why doesn't this code work?
Because it has syntax errors and undefined behavior. If you clean it up so that it works, you get this:

I assume you didn't understand my question. The code should output what apoc wanted it to.

that is why
Code:
`printf("*\n" * stars);`
I believe the problem is in that statement.

`printf("*\n" * stars);`