Answer to Question #265266 in C for Rosie

Question #265266

Write a C program to find common divisors between two numbers in a given pair.

1
Expert's answer
2021-11-14T09:21:48-0500
int GCDVal(int u, int v)
{
    while (u != v)
    {
        if (u > v)	return GCDVal(u - v, v);
        else        return GCDVal(u, v - u);
    }
    return u;
}


main(void)
{
    int n1, n2, i, gcd;
    printf("Enter First  Integer: "); scanf("%d",&n1);
    printf("Enter Second Integer: "); scanf("%d",&n2);
    gcd = GCDVal(n1,n2);
	printf("G.C.D of %d and %d is %d", n1, n2, gcd);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS