Solution 1
Video Link
#include<stdio.h>
main()
{
int a,b,num1, num2,temp,gcd;
printf("Enter First number");
scanf("%d",&num1);
printf("Enter Second number");
scanf("%d",&num2);
a=num1;
b=num2;
for(;a>0;)
{
temp=a;
a=b%a;
b=temp;
}
gcd=b;
printf("\n Gredest Common Divisor of %d and %d = %d", num1,num2,gcd);
}
Solution 2
#include<stdio.h>
main()
{
int num1,num2,gcd,temp,a,b;
printf("Enter first number?");
scanf("%d",&num1);
printf("Enter second number?");
scanf("%d",&num2);
a=num1;
b=num2;
for(;b>0;)
{
temp=b;
b=a%b;
a=temp;
}
gcd=a;
printf("\n Grreatest common divisor of %d and %d= %d",num1,num2,gcd);
}
0 comments:
Post a Comment