So what is happening is that I run this code and when I run the divide function it will sometimes crash or say that I entered a wrong answer when it’s correct. I know I need to check option while loop but I'm not too concerned with that at the moment. Please check the divide function and tell me what I need to revise.

So what is happening is that I run this code and when I run the divide function it will sometimes crash or say that I entered a wrong answer when it’s correct. I know I need to check option while loop but I'm not too concerned with that at the moment. Please check the divide function and tell me what I need to revise.Code:bool check_flat(int x, int y) //checks that two numbers divide evenly to one another { int int_check = x/y; double check_x = x; double check_y = y; double double_check = check_x/check_y; if (int_check < double_check) return (false); else return (true); } double dividing (int x, int y) //dividing fuction (this is giving me problems) { bool flat = false; int first_number; int second_number; int greater_number; int lesser_number; while (flat == false) //when I mean flat I mean the two numbers divide evenly to one another, no decimals { first_number = rand() % (x - y + 1); second_number = rand() % (x - y + 1); if (first_number > second_number) //checks to find the bigger of the two numbers and then set one to greater_number and one to lesser_number { greater_number = first_number; lesser_number = second_number; } else { greater_number = second_number; lesser_number = first_number; } flat = check_flat(greater_number, lesser_number); //calls check_flat function } int main() { time_t seconds; time(&seconds); srand((unsigned int) seconds); int max; int min; int option; int difficulty; cout << "Math practice"; cout << "What would you like to practice? \n" << "1. Adding \n" << "2. Subtracting \n" << "3. Multiplying \n" << "4. Dividing \n"; cin >> option; //type of math problems cout << "Difficulty? \n" << "1. Very Easy (1-5) \n" << "2. Easy (1-10) \n" << "3. Medium (5-15) \n" << "4. Difficult (1-25) \n" << "5. Very Difficult (1-50) \n" << "6. Extremely Difficult (1-100) \n"; cin >> difficulty; //range of numbers while ((difficulty < 1)||(difficulty > 6)) //checking difficulty { cout << "Enter a difficulty between 1 through 6 \n" << "1. Very Easy (1-5) \n" << "2. Easy (1-10) \n" << "3. Medium (5-15) \n" << "4. Difficult (1-25) \n" << "5. Very Difficult (1-50) \n" << "6. Extremely Difficult (1-100) \n"; cin >> difficulty; } switch(difficulty) //sets max and min randoms to be generated { case 1: min = 1; max = 5; break; case 2: min = 1; max = 10; break; case 3: min = 5; max = 15; break; case 4: min = 1; max = 25; break; case 5: min = 1; max = 50; break; case 6: min = 1; max = 100; break; } for(int i = 10; i >= 1; i--) //generates 10 problems at a time { switch (option) { case 1: adding(min, max);break; //calls adding fuctions case 2: subtracting(min, max);break; //calls subtracting fuctions case 3: multiplying(min, max);break; //calls multiplying fuction case 4: dividing(min, max);break; //calls dividing fuction } } system("PAUSE"); //pauses system }

Thank you,

ShadowIII