H.C.F of Two Number In Cpp
Program:
#include <iostream.h>
#include<conio.h>
int hcf(int n1, int n2);
void main()
{
clrscr();
int n1, n2;
cout << " Enter two positive integers: \n";
cout << " Number First : ";
cin >> n1;
cout << " Number Second : ";
cin >> n2;
cout << " H.C.F of " << n1 << " & " << n2 << " is: " << hcf(n1, n2);
getch();
}
int hcf(int n1, int n2)
{
if (n2 != 0)
return hcf(n2, n1 % n2);
else
return n1;
}
Output:

(Visited 188 times, 1 visits today)
Written by: