Cone Loop

Having trouble with a loop

Page 1 of 1

0 Replies - 1348 Views - Last Post: 28 July 2008 - 01:35 PM Rate Topic: -----

#1 mazer451  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 02-October 06

Cone Loop

Posted 28 July 2008 - 01:35 PM

hi,
I'm having a little trouble with a basic loop. the loop needs to output a cone for the top and bottom of a rocket being cout'ed to the screen.
the output now is:
(centered on screen, of course)
*
**
***
****
*****

but needs to look like this:
(centered on screen, of course)
*
* *
* *


any suggestions?
here is my code:
void drawCone(int coneWidth)
{
	int coneHeight = coneWidth/1.5; 
	//cout << coneHeight << coneWidth <<endl;
	int count=1, innerCount=1;
	while (count <= coneWidth)
	{
		  innerCount=1;
		  while (innerCount <= (coneWidth+1 -count)/2)
		  {
				cout << ' ';
				innerCount++;
		  }
		  innerCount=1;
		  while (innerCount <=count)
		  {
				cout << '*';
				innerCount++;
		  }
		  cout << endl;
		  count++;
	}	 
	 
}


This post has been edited by mazer451: 28 July 2008 - 01:56 PM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1