g.c.d of two number
void main()
{
int n1,n2;
clrscr();
printf("\nEnter two numbers:");
scanf("%d %d",&n1,&n2);
while(n1!=n2)
{
if(n1>n2)
n1=n1-n2;
else
n2=n2-n1;
}
printf("\nGCD=%d",n1);
getch();
}
void main()
{
int n1,n2;
clrscr();
printf("\nEnter two numbers:");
scanf("%d %d",&n1,&n2);
while(n1!=n2)
{
if(n1>n2)
n1=n1-n2;
else
n2=n2-n1;
}
printf("\nGCD=%d",n1);
getch();
}
Posted by Naresh Kumar at 5:07 AM
Labels: G.C.D of two numbers
0 comments:
Post a Comment