#include<stdio.h>

#include<conio.h>

int gcd (int, int); //func. declaration.

void main( )

{

int a, b, res;

clrscr( );

printf("Enter the two integer values:");

scanf("%d%d", &a, &b);

res= gcd(a, b); // calling function.

printf("\nGCD of %d and %d is: %d", a, b, res);

getch( );

}

int gcd( int x, int y) //called function.

{

int z;

z=x%y;

if(z==0)

return y;

gcd(y,z); //recursive function

}

#include<conio.h>

int gcd (int, int); //func. declaration.

void main( )

{

int a, b, res;

clrscr( );

printf("Enter the two integer values:");

scanf("%d%d", &a, &b);

res= gcd(a, b); // calling function.

printf("\nGCD of %d and %d is: %d", a, b, res);

getch( );

}

int gcd( int x, int y) //called function.

{

int z;

z=x%y;

if(z==0)

return y;

gcd(y,z); //recursive function

}

## No comments:

## Post a Comment