944,123 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1729
  • C++ RSS
Jul 29th, 2005
0

newcommer to c++ need help with simple program

Expand Post »
hello all . well its pretty simple but i need to get this for loop sorted before i can move on.

C++ Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rks01 is offline Offline
7 posts
since Jul 2005
Jul 29th, 2005
0

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

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++) ...
Reputation Points: 10
Solved Threads: 1
Newbie Poster
The Senate is offline Offline
6 posts
since Jul 2005
Jul 29th, 2005
0

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

ah thank you .. got it the wrong way round thank you!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rks01 is offline Offline
7 posts
since Jul 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Need hellp with my array
Next Thread in C++ Forum Timeline: MFC Compiling Error Question





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC