1. ## for loop

hello all,

I'm university student and i have final exam in c++ on monday very soon
so
i need some help

how to write a program in for loop the given output

Code:
```

*
***
*****
*******```

this is what i tried
Quote:
int n =5;

for(int i=1; i<n+1 ;i++)
{cout << endl;
for(int j=1; j<i+1; j++)
cout << "*";
}
and the output came out like this
*
**
***
****
*****
but now i dont know how to make the first stars be in the middle of the line
what ways can i make it???
do i need to use a third for loop hope not for loops make my head hurts

thanks

2. What have you tried?

3. You're right, you need a for loop.
One which counts from 1 to 5 seems like a good bet.

Now, what have YOU tried to do, apart from just posting your assignment?
See the forum rules if you're still unclear.

4. this is not assignment this a Q came out in previous papers
and im asking for my styding

u might not believe i understand
anyways

this is what i tried
int n =5;

for(int i=1; i<n+1 ;i++)
{cout << endl;
for(int j=1; j<i+1; j++)
cout << "*";
}
but i dont know how to make the first stars be in the middle of the line
what ways can i make it???

and thank you for the fast replys

5. Maybe investigate the relationship between the number of leading spaces compared to the number of stars on each line.

> but i dont know how to make the first stars be in the middle of the line
See, if this was your first post, you'd have gotten a lot more positive attention.
It shows effort, and a specific question.

As opposed to the zero effort "here's my homework, gimme an answer" which characterised your first missive.

6. thank u mr.salem
i appreciate ur welling to help and ur advise

7. I normally refrain from nit-picking.... well nit-picking grammar, anyway. Advice and advise are not the same word. At least you didn't spell lose wrong. That drives me crazy.

8. If you're already nitpicking spelling or grammar, you may as well point out that netspeak is frowned upon on this forum.

9. I was born with a rare brain disorder that doesn't allow the images of netspeak to even be fully processed by my brain. Thus I only see:

thank mr.salem
i appreciate welling to help and advise

10. Originally Posted by master5001
I normally refrain from nit-picking.... well nit-picking grammar, anyway. Advice and advise are not the same word. At least you didn't spell lose wrong. That drives me crazy.
thanks for the help
and sorry for driving you crazy

11. Ah but you didn't, friend. You have a loooooooooooooooong way to go before that You didn't spell lose as loose.

Do you see the pattern between base and leading whitespace?