WAP to Find HCF of Two Numbers using Recursion.

#include<stdio.h>

#include<math.h>

int main()

{

    int x,y,r;

    printf("Enter the values of x and y = ");

    scanf("%d %d",&x,&y);

    r=hcf(x,y);

    printf("hcf of x and y is %d",r);

}

int hcf(int a, int b) {

  if (b == 0) {

    return a;

  }

  else

    {

    return hcf(b, a % b);

  }

}
WAP to Find HCF of Two Numbers using Recursion. WAP  to Find HCF of Two Numbers using Recursion. Reviewed by Unknown on 03:38 Rating: 5

No comments:

Powered by Blogger.