Find the greatest common divisor of two integers
What will be an ideal response?
```
{
int n1;
int n2;
int divisor;
int dividend;
int remainder;
cout << "Enter integer 1: ";
cin << n1;
cout << "Enter integer 2: ";
cin << n2;
divisor = abs( n1 );
dividend = abs( n2 );
for ( remainder = dividend % divisor;
remainder != 0;
remainder = dividend % divisor) {
dividend = divisor;
divisor = remainder;
}
cout << "The GCD is: " << divisor << endl;
return 0;
}
```
You might also like to view...
If an assigned task is ____________________, it comes back to you.
Fill in the blank(s) with the appropriate word(s).
If you assign float pi = 3.141592654;, what actually will be stored in memory?
A. 3.14000 B. 3.141593 C. 3.141592654 D. 3
The most common solution for installing multiple displays is to buy a motherboard that has two video ports
Indicate whether the statement is true or false
If active cell D12 contains the formula =D10+D11, cells D10 and D11 are _______ cells for D12.
A. feeder B. dependent C. precedent D. formula