Introduction
I have used CodeBlocks compiler for debugging purpose. But you can use any C++ programming language compiler as per your availability.
#include <iostream> using namespace std; int Findgcd(int x, int y); // Function declaration int main() { int num1, num2, hcf; // Inputting 2 numbers from user cout<<"Enter any 2 numbers to find HCF or GCD: "<<endl; cin>>num1; cin>>num2; hcf = Findgcd(num1, num2); //printf("GCD of %d and %d = %d", num1, num2, hcf); cout<<"GCD of "<<num1 <<" and "<<num2 <<" = "<<hcf; return 0; } int Findgcd(int x, int y) { if(y == 0) return x; else return Findgcd(y, x%y); }