This is a program testing for prime numbers in a specific range,using an .in file and writing to an .out one.
My question is why after a certain range of number e.g.when i set 234 to 234353 it outputs giberish?Also any ideas to NOT have a space character after the last number would be apreciated because my method obviously is wrong for some reason..
using namespace std;
bool ISPRIME(int K)
if (K == 2)
if (K % 2 == 0)
for (int d = 11; d <= (int)sqrt((double)K); d=d+2)
if (K % d == 0)
read = fopen ( "function.in" , "r" ) ;
fscanf ( read , "%d" , &N ) ;
fscanf ( read , "%d" , &M ) ;
int K = ( N < M ) ? (N+1) : (M+1) ;
int d = ( N < M ) ? (M-1) : (N-1) ;