#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,max,min,r;
clrscr();
printf("Enter the values of a,b\n");
scanf("%d%d",&a,&b);
if(a>b)
{
max=a;
min=b;
}
else
{
max=b;
min=a;
}
while((max%min)!=0)
{
r=max%min;
if(r==0)
{
break;
}
max=min;
min=r;
}
printf("GCD=%d",min);
getch();
}
#include<conio.h>
void main()
{
int a,b,max,min,r;
clrscr();
printf("Enter the values of a,b\n");
scanf("%d%d",&a,&b);
if(a>b)
{
max=a;
min=b;
}
else
{
max=b;
min=a;
}
while((max%min)!=0)
{
r=max%min;
if(r==0)
{
break;
}
max=min;
min=r;
}
printf("GCD=%d",min);
getch();
}
No comments:
Post a Comment