/* GCD OF TWO NUMBERS */
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,gcd;
clrscr();
printf("\n\t\tINPUT:");
printf("\n\t\t------");
printf("\n\t\tEnter two numbers: ");
scanf("%d%d",&a,&b);
gcd=recgcd(a,b);
printf("\n\t\tOUTPUT:");
printf("\n\t\t-------");
printf("\n\t\tThe GCD of %d and %d is = %d ",a,b,gcd);
getch();
}
int recgcd(int x, int y)
{
int r;
if(y = = 0)
{
return(x);
}
else
{
r=x%y;
return(recgcd(y,r));
}
}
INPUT:
------
Enter two numbers:
8
4
OUTPUT:
-------
The GCD of 8 and 4 is = 4
No comments:
Post a Comment