How to loop chars (*)

Hey guys!

I am brand new to c++ programming and found a site on google: http://issc.uj.ac.za/appliedmaths/excpp.html for some beginner c++ exercises, i know this site has some too but i figured do them all :).

So im starting problem 1 and I know how to loop integers using the for loop but i dont know how to loop stuff like an asterisk (*) or characters. If anyone could help me out or lead me to a page that could help.

Thanks alot :)
When starting out with C++, you'll find out that your answer to your problems are actually a lot simpler than you think they are.

How you would do it would be like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
int count = 1;

// while count is 8 or lower
while (count <= 8) {

    // send out the asterisks
    for (int i = 1; i <= count; i++) {
        cout << "*";
    }
    
    // send out a new line
    cout << "\n";
    
    // increase the count
    count++;
}


There are many ways to answer to this solution, this is just one of the more simpler ones.
Durrr I didn't really read the original post so this isn't valid
Last edited on
Shadow Addict, no offense, but did you even check the link that he got this programming exercise from?

It said to create a program that gave this output:
1
2
3
4
5
6
7
8
*
**
***
****
*****
******
*******
********

Thanks for the reply's.

Yeh i kind of get it now, im just gonna play around with it abit, now that i have a general idea and read on some tuts aswell. Thanks plenty :)
... No I didn't. I got ahead of myself, sorry for the dumb reply!
Topic archived. No new replies allowed.