446,389 Members | 1,881 Online
Need help? Post your question and get tips & solutions from a community of 446,389 IT Pros & Developers. It's quick & easy.

Loop Problem--help

 P: 40 I want to make an output like a Christmas Tree but...my code shows only half of it... * ** *** **** ***** What's wrong with my loop? for(x=1;x<=5;++x){ for(y=0;y
6 Replies

 Expert 100+ P: 1,510 you need to print spaces before the *, 5 on first line, 4 on second, etc so you get the triangle indented Mar 7 '07 #2

 P: 40 you need to print spaces before the *, 5 on first line, 4 on second, etc so you get the triangle indented just a follow up question...does C++ have a gotoxy(col, row) like in Turbo C? if not what does C++ have in lieu of the col, row in turbo c..thanx for the reply Mar 7 '07 #3

 Expert 2.5K+ P: 3,652 C++ doesn't have this, but if you look up the conio header file, you can use the goto(x, y) function normally. Mar 7 '07 #4

 P: 40 you need to print spaces before the *, 5 on first line, 4 on second, etc so you get the triangle indented where am i going to put the spaces? before the second for loop or after the two loop? am i going to use "\t"? Mar 7 '07 #5

 Expert 100+ P: 1,510 where am i going to put the spaces? before the second for loop or after the two loop? am i going to use "\t"? Expand|Select|Wrap|Line Numbers for(x=1;x<=5;++x){   <<<   print spaces here! for(y=0;y

 P: 40 Expand|Select|Wrap|Line Numbers for(x=1;x<=5;++x){   <<<   print spaces here! for(y=0;y