#include<stdio.h>
int main()
{
int firstnum,secondnum;
printf("enter the first number\n");
scanf("%d",&firstnum);
printf("enter the second number\n");
scanf("%d",&secondnum);
int i,small=firstnum<secondnum?firstnum:secondnum;
int gcd;
for(i=1;i<=small;i++)
{
if(firstnum%i==0 && secondnum%i==0)
{
gcd=i;
}
}
printf("\n the GCD of %d and %d is: %d\n",firstnum,secondnum,gcd);
}
Output:
Comments
Post a Comment