- 2
pls write a program to input 2 nos. and tell whether they are twin primes or not... save it and tell me the code name I will have a look at it.
7 Réponses
+ 2
Again, this looks so much like a homework assignment... As a former educator in computer science it saddens me a little as someone might have wasted an opportunity to learn.
+ 1
agreeing with Stefan here, I actually had a blast writing this code. It's a little over complicated, but that was part of the fun. nonetheless this http://www.sololearn.com/app/cplusplus/playground/cP6xY2cId5cv should give you a rough idea for an approach and teach a thing or two. feel free to modify/spruce it up, cheers!
0
twin primes?
0
I tried it on my own but was not able to complete it
0
thx sid and destro
- 1
yes search on net what are twin primes..... they are 2 consecutive prime no's.
- 1
bool twins = true;
if(no1 == no2) twins = false;
else if(isPrime(no1) && isPrime(no2)) {
for(int i = min(no1, no2) + 1; i < max(no1, no2); ++i) {
if(isPrime(i)) {
twins = false;
break;
}
}
}
else twins = false;
cout << twins;