newcommer to c++ need help with simple program

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2005
Posts: 7
Reputation: rks01 is an unknown quantity at this point 
Solved Threads: 0
rks01 rks01 is offline Offline
Newbie Poster

newcommer to c++ need help with simple program

 
0
  #1
Jul 29th, 2005
hello all . well its pretty simple but i need to get this for loop sorted before i can move on.

  1. #include <iostream.h>
  2.  
  3. void square();
  4. void circle();
  5. void arrow();
  6. void diamond();
  7.  
  8. using std::cout;
  9. using std::endl;
  10.  
  11. void square()
  12. {
  13. //first line
  14. for (int e = 1; e >= 9; e++)
  15. {
  16. cout << "*";
  17. }
  18.  
  19. }
  20.  
  21.  
  22. int main()
  23. {
  24. square();
  25. return 0;
  26. }
<< moderator edit: added [code][/code] tags >>

so thats it .. and it wont print the stars . if i comment out the loop then it will display a star. so i dont know whats going on i cant see any error in the syntax or logic. so any help is appreciated thank you.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 6
Reputation: The Senate is an unknown quantity at this point 
Solved Threads: 1
The Senate The Senate is offline Offline
Newbie Poster

Re: newcommer to c++ need help with simple program

 
0
  #2
Jul 29th, 2005
In the "for", you stated the following:
e=1; e>=9; e++
So, it means that e is first 1 and it will grow each cycle while e>=9 (simply isn't possible-e=1). To correct this, just make the for like this:

for (e=1;e<=9;e++) ...
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 7
Reputation: rks01 is an unknown quantity at this point 
Solved Threads: 0
rks01 rks01 is offline Offline
Newbie Poster

Re: newcommer to c++ need help with simple program

 
0
  #3
Jul 29th, 2005
ah thank you .. got it the wrong way round thank you!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC