Showing posts with label calculate HCF of two number. Show all posts
Showing posts with label calculate HCF of two number. Show all posts

Monday, September 12, 2011

Calculate HCF of two numbers

main()
{
    int a,b;
    clrscr();
    printf("\n Enter any two nos.:");
    scanf("%d %d",&a,&b);
    printf("\n HCF of the two nos.:%d",gcd(a,b));
    getch();
}

    gcd(int n,int d)
    {
      int r;
      do{
         r=n%d;
         n=d;
         d=r; }while(r!=0);
      return(n);
      }

Popular 5 Posts Last 7 days