/* gcd.c
   Compute the greatest common divisor of two integers
*/

#include <stdio.h>

struct param_t {
    int x;
    int y;
};

int computeGCD (struct param_t);

int main()
{
    struct param_t params;

    printf("enter x: ");
    scanf ("%d", &(params.x));
    printf("enter y: ");
    scanf ("%d", &(params.y));

    printf ("gcd = %d\n", computeGCD(params));
    return 0;
}

int computeGCD(struct param_t params)
{
    while (params.x != params.y)
    {
        if (params.x > params.y)
            params.x -= params.y;
        else
            params.y -= params.x;
    }
    return params.x;
}