Monday 18 January 2016

// // Leave a Comment

GREATER COMMON DIVISOR

C++ Program Finding Greater Common Divisor

#include<iostream>
using namespace std;
unsigned int gcd (unsigned int n1, unsigned int n2)
{
    unsigned int tmp;
    while (n2 != 0) {
        tmp = n1;
        n1 = n2;
        n2 = tmp % n2;
    }
    return n1;
}
int main()
{
unsigned int gcd(unsigned int,unsigned int );
int num1,num2;
cin>>num1;
cin>>num2;
cout<<"greater common divisor is :"<<gcd(num1,num2)<<"\n";
system("pause");
}



*------------------------------------------------------------------------------------------------------*


0 comments:

Post a Comment