Hey what wrong with this code. when run this code its showing some error floating point exception(core dumbed).I used g++ to compile this program.
#include <iostream>
using namespace std;
int checkprime(int num){
int ch=0;
for (int n=2;n<num;n++){
if (num%n==0){ ch=ch+1 ;}}
if (ch==0){return num;}
else{return -1; }
}
int main(){
int prt=0;int a=2;long long int pri=600851475143;int arr_pr_fac[100];
int re;
while(a<pri){
a++;
if (pri%a==0){ re=checkprime(a) ;
if (re>0){arr_pr_fac[prt]=re;prt++;cout<<re<<endl;}
}
}
for(int th=0;th<4;th++){cout<<arr_pr_fac[th]<<endl;};
}