Can someone help me with my C++ program. For some reason I Compile the program, but when I run it I have problems. I type in the first integer, then I type in the second integer and the program times out (ie it disappears). I start over and it does the same thing.
[CODE=cpp]#include <iostream>
using namespace std ;
int main()
{
int x, y, temp, remainder;
// read in the two integers
cout << endl ;
cout << "Enter the first number (integer) : " ;
cin >> x ;
cout << "Enter the second number (integer) : " ;
cin >> y ;
// echo inputs
cout << "Input numbers are: " << x << " , " << y << endl;
{// exchange values of x and y
if(x == y)
{
return x;
}
else if(x < y)
{
y = y - x ;
}
else
{
x = x - y ;
}
}
/* At this point we will always have x >= y */
//Initialize remainder.
while (x > 0)
{
temp = x % y;
x = y;
y = temp;
}
// display the result
cout << endl ;
cout << "The GCD is: " << y << endl ;
system("PAUSE") ;
return (0); // terminate with success
}[/CODE]
[CODE=cpp]#include <iostream>
using namespace std ;
int main()
{
int x, y, temp, remainder;
// read in the two integers
cout << endl ;
cout << "Enter the first number (integer) : " ;
cin >> x ;
cout << "Enter the second number (integer) : " ;
cin >> y ;
// echo inputs
cout << "Input numbers are: " << x << " , " << y << endl;
{// exchange values of x and y
if(x == y)
{
return x;
}
else if(x < y)
{
y = y - x ;
}
else
{
x = x - y ;
}
}
/* At this point we will always have x >= y */
//Initialize remainder.
while (x > 0)
{
temp = x % y;
x = y;
y = temp;
}
// display the result
cout << endl ;
cout << "The GCD is: " << y << endl ;
system("PAUSE") ;
return (0); // terminate with success
}[/CODE]
Comment