Saturday, November 5, 2011

HCF in C language


#include<stdio.h>
int hcf(int a,int b)
{
int r=1,t;

while(r!=0)
{
r=b%a;
b=a;
a=r;
}

return(b);
}

void main()
{
int a,b,c;
printf("Plese enter two numbers:");
scanf("%d %d",&a,&b);
c=hcf(a,b);
printf("HCF: %d",c);

}

0 comments:

Post a Comment

You are most welcome for making comments here. I will consider your view and will reply you soon.