summaryrefslogtreecommitdiff
path: root/Q3a.cpp
diff options
context:
space:
mode:
authorMichael Abed <michaelabed@gmail.com>2012-03-05 14:28:10 -0500
committerMichael Abed <michaelabed@gmail.com>2012-03-05 14:28:10 -0500
commit1c03e941f1015c48917ddc603d84b134eb705f10 (patch)
treed89b07d63a12b5542882328c679bb76fb23a5f63 /Q3a.cpp
parentf2566da91396bc07356601794fd5db858a78f1f3 (diff)
downloadec327-lab2-master.tar.gz
ec327-lab2-master.tar.bz2
ec327-lab2-master.zip
finish it all upHEADmaster
Diffstat (limited to 'Q3a.cpp')
-rw-r--r--Q3a.cpp18
1 files changed, 3 insertions, 15 deletions
diff --git a/Q3a.cpp b/Q3a.cpp
index cbe9023..09bbf0d 100644
--- a/Q3a.cpp
+++ b/Q3a.cpp
@@ -8,7 +8,7 @@ int gcd(int m, int n);
int gcd(int m, int n)
{
if (m <= 0 || n <= 0)
- return 0;
+ return 0; // invalid
if (m % n == 0)
return n;
@@ -18,19 +18,7 @@ int gcd(int m, int n)
int main(int argc, const char *argv[])
{
- int m, n;
- int result;
- cout << "Enter 2 numbers to calculate the greatest common divisor (0 to quit)" << endl;
- do {
- cout << ">> ";
- cin >> m >> n;
- if (m <= 0 || n <= 0) {
- cout << "Please input positive numbers (0 to quit)" << endl;
- } else {
- result = gcd(m, n);
- cout << "gcd(" << m << ", " << n << ") = " << result << endl;
- }
- } while (m != 0 || n != 0);
-
+ cout << "gcd(24,16) = " << gcd(24,16) << endl;
+ cout << "gcd(255, 25) = " << gcd(255,25) << endl;
return 0;
}