944,083 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 742
  • C++ RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Nov 1st, 2009
0
Re: Loop help and such.
Okay so taking the else conditions out makes it reachable?

After doing that I still cant get it to work, I dont think main is calling the while function correctly any advice?
Reputation Points: 10
Solved Threads: 1
Light Poster
UKmason is offline Offline
43 posts
since Oct 2009
Nov 1st, 2009
1
Re: Loop help and such.
You're going to return from main in one of two places:
int main () 
{
int number;
int counter = 0;
int flags = 1;
bool flag_none = true;
bool fag_yes = false;

	  cout << "Enter a number, hit enter to confirm, and repeat to test flags: " << endl;
      cout << endl;
    
while (counter < 7)
{	
	cin >> number;
	cout << "Echoing number, you entered " << number << endl;
	
		if (number >= 10 && number <= 500)
		{
			return true;
		}
		else
		{
			return false;
		}

counter ++;
}

if (counter < 7 == true)
{
	cout << "Number " << counter << " is between 10 and 500" << endl; 
	cout << "Number " << counter << " is not flagged. " << endl;
}

else (counter < 7 == false);
{	
	cout << "Number " << counter << " is either less than 10 or more than 500" << endl; 
	cout << "Number " << counter << " is flagged." << endl; 
	cout << "There have been " << (flags ++) << " flags";
}
}
Right?
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Nov 2nd, 2009
0
Re: Loop help and such.
Ah, yes.
*smacks head*
Thanks for the help
Reputation Points: 10
Solved Threads: 0
Newbie Poster
A Tripolation is offline Offline
12 posts
since Nov 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

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: i want to know......
Next Thread in C++ Forum Timeline: sort code & write exchange increment line





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


Follow us on Twitter


© 2011 DaniWeb® LLC