Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > nested for loop...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 10 Topic 45760 of 45898
Post > Topic >>

nested for loop problem

by notahipee <werldpeace@[EMAIL PROTECTED] > May 5, 2008 at 11:42 AM

Would someone be able to tell me why this isn't working. The nested
for loops seem correctly coded to me. I would appreciate any input.

#include <iostream.h>
#include <math.h>

int main ()
{
	int a, b, c, d;

	cout << "Enter two integers ";
		cin >> a >> b;

	for (c=a; c==b; c++)
	{
		for(d=2; d<=sqrt(c); d++)
		{
			if(c%d==0)
				continue;

			else cout << c;
		}
	}
	cout << " are the prime numbers in the range " << a << " to " << b <<
endl;

	return 0;
}




 10 Posts in Topic:
nested for loop problem
notahipee <werldpeace@  2008-05-05 11:42:26 
Re: nested for loop problem
"Victor Bazarov"  2008-05-05 14:47:15 
Re: nested for loop problem
red floyd <no.spam@[EM  2008-05-05 11:50:30 
Re: nested for loop problem
Christopher <cpisz@[EM  2008-05-05 11:53:08 
Re: nested for loop problem
notahipee <werldpeace@  2008-05-05 11:56:57 
Re: nested for loop problem
notahipee <werldpeace@  2008-05-05 12:01:05 
Re: nested for loop problem
notahipee <werldpeace@  2008-05-05 12:05:13 
Re: nested for loop problem
notahipee <werldpeace@  2008-05-05 12:17:40 
Re: nested for loop problem
Puppet_Sock <puppet_so  2008-05-05 13:25:56 
Re: nested for loop problem
MiB <Michael.Boehnisch  2008-05-06 09:12:50 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue May 13 14:51:31 CDT 2008.