Hi, I've just started learning C++ and I have a problem figuring out an assignment. It would be really great if someone could please help me. :icon_cheesygrin:

The program should look something like this:
Input number: 6
(then the program should read out following)
*
**
***
****
*****
******

This is what I've done so far:
(am I thinking right at all here? :icon_rolleyes:)

int _tmain(int argc, _TCHAR* argv[])
{
	char teck='*';
	int rep;
	cout<<"Input number: ";
	cin>>rep;
	for(int z=0; z<=rep; z++)
		cout<<char(teck)<<endl;

	return 0;
}

But this only make the *'s line up, like this:
*
*
*

How do I get them to add an extra * on each line?

Try putting another loop inside of your present loop where the outer loop handles rows and the inner loop handles columns.

Another loop.

line by line your program prints a number of '*'.

so for each line, print your number of '*' and then move to the next line, and run that loop again.

for( ;; )
{
for( ;; )
{
}
}

Oh thank you ^^ I get it now :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.