English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

it must be simple with loops and switch just i don't want it with structures or classes just simple

2007-01-08 22:12:00 · 2 answers · asked by bafr 1 in Computers & Internet Programming & Design

2 answers

For future reference, this algorithm is called Euler's Algorithm for finding GCD of two integers.

#include

int main() {

int a;
int b;
int temp;

cout << "Enter the 1st integer : ";
cin >> a;
cout << "Enter the 2nd integer : ";
cin >> b;

while( b!= 0) {

temp = a % b;
a = b;
b = temp;
}

cout << a << endl;

return 0;
}

2007-01-09 00:34:17 · answer #1 · answered by Kookiemon 6 · 0 2

check out the below link, from the below blog i got the latest logic:

http://www.programmingtunes.com/finding-greatest-common-divisor-of-2-numbers-c/

2014-03-22 10:31:28 · answer #2 · answered by Anonymous · 0 0

fedest.com, questions and answers