#include<iostream> void main() { using namespace std; int num1,num2; cout<<"Enter 1st no. "; cin>>num1; cout<<"Enter 2nd no. "; cin>>num2; while(num1!=num2) { if(num1>num2) { num1 = num1-num2; } else { num2 = num2-num1; } } cout<<"GCD is = "<<num1; cin.get(); }
Responses
0 Respones to "Program to find the GCD of a number using C++"
Post a Comment