//Written by MA Saleh
#include<stdio.h>
int main()
{
int a, b, t;
printf("Enter Two Number for find GCD: ");
while(scanf("%d %d", &a, &b) == 2) //Take two number as input
{
if(a == 0)
{
printf("Gcd = %d\n", b);
}
else if(b == 0 || a == b)
{
printf("Gcd = %d\n", a);
}
else if(a > b)
{
while(b != 0)
{
t = b;
b = a % b;
a = t;
}
printf("Gcd = %d\n", a);
}
else if(b > a)
{
while(a != 0)
{
t = a;
a = b % a;
b = t;
}
printf("Gcd = %d\n", b);
}
printf("Again give two number: \n");
}
return 0;
//Copyright@MAS
}
#include<stdio.h>
int main()
{
int a, b, t;
printf("Enter Two Number for find GCD: ");
while(scanf("%d %d", &a, &b) == 2) //Take two number as input
{
if(a == 0)
{
printf("Gcd = %d\n", b);
}
else if(b == 0 || a == b)
{
printf("Gcd = %d\n", a);
}
else if(a > b)
{
while(b != 0)
{
t = b;
b = a % b;
a = t;
}
printf("Gcd = %d\n", a);
}
else if(b > a)
{
while(a != 0)
{
t = a;
a = b % a;
b = t;
}
printf("Gcd = %d\n", b);
}
printf("Again give two number: \n");
}
return 0;
//Copyright@MAS
}