### Having problems with Euclid's Algorithm

I am trying to make a Euclid’s Algorithm with Loop While process.
I need to get the program to:
input: smaller number followed by larger & output: greatest common divisor
2. print out both numbers
3. REMAINDER = remainder of LARGER/SMALLER.
4. Loop while REMAINDER is not zero:
a. Set LARGER to SMALLER.
b. Set SMALLER to REMAINDER.
c. REMAINDER = remainder of LARGER/SMALLER.
d. End loop.
5. Print ‘Greatest common divisor is,’SMALLER.
6. end the program.....

So far I have:
 ``123456789101112131415161718192021222324252627282930`` ``````#include using namespace std; int main() { int a; int b; int remainder; cout << "Please select an integer for a\n"; // value a must less than value b cin >> a; // select a value cout << "Please select an integer for b\n"; // value b must be greater than a cin >> b; // select a value greater than value a cout << "The smaller number is: " << a; // outputs the smaller value cout << "The larger number is: " << b; // outputs the greater value remainder = a % b while (remainder != 0) { b = a a = remainder remainder = b/a } cout << endl; cout << "Greatest common divisor is: " << a; return 0; } ``````

all my compiler is telling me is that line 20 has
[error: expected ';' before 'while']
Of course, put a semicolon (;) in the lines 18, 22-24.
Thank you (^~^)
You're welcome! :))
Topic archived. No new replies allowed.