0

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?

Edited by Narue: Added code tags

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by FoxInBoots
0

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

0

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( ;; )
{
}
}

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.