446,190 Members | 811 Online
Need help? Post your question and get tips & solutions from a community of 446,190 IT Pros & Developers. It's quick & easy.

# I need some help, Please!

 P: 8 Expand|Select|Wrap|Line Numbers #include  using namespace std;   int GCD(int a, int b) {    while(1)    {       a = a % b;          if(a ==0)             return b;          b = b % a;       if(b == 0)          return a;    } }   int LCM(int x, int y) {    int i;    if (x > Y)       for(i = y; i <= x * y; i++)       {          if (i % x == 0 && i % y ==0)             return i;       }    else       for(i = y; i <= x * y; i++)       {          if(i % x == 0 && i % y ==0)             return i;       }    return i; }   int main() {    char cAgain;    int x, y;      do    {       cout << endl << "Please enter value one: " << endl << endl;       cin >> x;       cout << endl << "Please enter value two: " << endl << endl;       cin >> y;       cout << endl << "The Greatest Commin Factor of "            << x << " and " << y << " is " << GCD(x,y) << endl;       cout << endl << "The Least Common Multiple of "             << x << " and " << y << " is " << LCM(x,y) << endl;       cout << "Would you like to calculate another? Y/y/N/n"            << endl << endl;       cin >> cAgain;    }while(cAgain == 'Y' || cAgain == 'y');      cout << endl << "Thank you for using this program." << endl;      return 0;   } There is my code. And it works except when i use the numbers -10 and zero in that order. The error says Floating Point Exception and just stops. So I was wondering what that means and how do I fix it in my code. Thanks Mar 19 '07 #1