Loop help and such.

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Oct 2009
Posts: 43
Reputation: UKmason is an unknown quantity at this point 
Solved Threads: 1
UKmason UKmason is offline Offline
Light Poster
 
0
  #11
23 Days Ago
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?
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,335
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 236
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c
 
1
  #12
23 Days Ago
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?
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 12
Reputation: A Tripolation is an unknown quantity at this point 
Solved Threads: 0
A Tripolation A Tripolation is offline Offline
Newbie Poster
 
0
  #13
22 Days Ago
Ah, yes.
*smacks head*
Thanks for the help
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC