Pages

Tuesday, January 20, 2015

Find the G.C.D of two number

#include<stdio.h>
#include<conio.h>
void main()
{
int x,y,t;
printf("Enter two number:-");
scanf("%d%d",&x,&y);
if(x<0)
x=-x;
if(y<0)
y=-y;
if((x==0)||(y==0))
printf("is not possible:-\n");
else
{
while(x!=y)
{
if(x>y)
{
t=x;
x=y;
y=t;
}
y=y-x;
}
printf("The GCD is=%d",x);
}
getch();
}

No comments:

Post a Comment