File name:- hcfrec.cpp
File name:- hcfrec.c
#include <iostream.h>
#include<conio.h>
#include<conio.h>
int main(){
int n1, n2;
int hcf(int n1, int n2);
clrscr();
int hcf(int n1, int n2);
clrscr();
cout<<"Enter two positive integers"<<endl;
cin>>n1>>n2;
cout<<"H.C.F of "<<n1<<" and "<<n2<<" is= "<<hcf(n1,n2)<<endl;
getch();
return 0;
return 0;
}
int hcf(int n1, int n2){
if (n2 != 0)
return hcf(n2, n1%n2);
else
return n1;
}
#include <stdio.h>
#include<conio.h>
#include<conio.h>
int main(){
int n1, n2;
int hcf(int n1, int n2);
clrscr();
int hcf(int n1, int n2);
clrscr();
printf("Enter two positive integers: ");
scanf("%d %d", &n1, &n2);
printf("H.C.F of %d and %d is %d.", n1, n2,
hcf(n1,n2));
getch();
return 0;
return 0;
}
int hcf(int n1, int n2){
if (n2 != 0)
return hcf(n2,
n1%n2);
else
return n1;
}
No comments:
Post a Comment