the question is wiritng a c++ code for printing all prime numbers between any 2 numbers( those two numbers are included.example:
input :
103
110
output :
103, 107 )
. please not use cout, cin  and getch() our library does not include those codes :D thnx for helping ...
Urgent c++ code please help me ?
This function might be helpful:
bool isPrime ( int p ){  // p is the candidate
  bool result = true;  // we assume that p is prime
  if ( i %26lt; 2 ){
    result = false; // if p is less than 2, it's not prime
  }
  else{
    for(int i = 2; i %26lt; p; ++p){
     if (p%i==0){  // if p is evenly divisible by anything.
      result = false;  // it's not prime
      break;
    }
  }
  return result;
}
In your main program, loop from the first number to the second. Use the function to determine whether or not the value is prime. HTH...
Subscribe to:
Post Comments (Atom)
 
No comments:
Post a Comment