GCF Program - cout<<"Value 1" cin>> x cout<<"Value 2" cin>> y cout<<"\nThe Greatest Common Divisor

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 #include <iostream> using namespace std int GCD(int a, int b) { while( 1 ) { a = a % b if( a == 0 ) return b b = b % a if( b == 0 ) return a } } int main() { int x, y cout << "This program allows calculating the GCD\n"
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cout << "Value 1: " cin >> x cout << "Value 2: " cin >> y cout << "\nThe Greatest Common Divisor of " << x << " and " << y << " is " << GCD(x, y) << endl return 0 }...
View Full Document

This note was uploaded on 05/16/2010 for the course CISCO EST61 taught by Professor Miller during the Spring '10 term at Fresno City College.

Ask a homework question - tutors are online