I get a floating point exception when running this program:
#include <stdio.h>
int check(int n)
{
int ii=0;
int jj=0;
int sum_of_dividors=0;
int sum_of_dividors2=0;
for (ii=0;ii<n;ii++){
for (jj=0;jj<ii;jj++){
if(ii%jj==0)
{
sum_of_dividors=sum_of_dividors+jj;
}
}
if(sum_of_dividors<n || ii<n){
for (jj=0;jj<sum_of_dividors;jj++){
if(sum_of_dividors%jj==0)
{
sum_of_dividors2=sum_of_dividors2+jj;
}
}
if (sum_of_dividors2==ii){
printf("%d and %d,",ii,sum_of_dividors);
}
}
sum_of_dividors=0;
sum_of_dividors2=0;
}
}
int main()
{
int n;
printf("Enter n ");
scanf("%d",&n);
printf("%d",check(n));
}
The code's purpose is to check the closest pair of amicable numbers to the number (n) that the user have entered.