Hello,
I have made a programm which calculated the GCD of two numbers.
For me it works.Code:#include <stdio.h> int main ( int argc, char *argv[] ) { int getal1, getal2, tmp, uitkomst, rest ; tmp = 0 ; printf ("Enter the two numbers where the GCD must be calculated \n") printf ("Please first the little number and then the greatest number. "); scanf ("%d %d", &getal1, &getal2) ; uitkomst = getal2 / getal1 ; rest = getal2 - uitkomst * getal1; while (rest > 1) { tmp = getal1 ; getal2 = getal1 ; getal1 = rest ; uitkomst = getal2/getal1 ; rest = getal2 - uitkomst * getal1; } if (rest == 0) printf("The GCD is %d",getal1 ); else printf("There is no GCD"); return 0 ;
But I wonder if you experts have anything to say about the programm.
Roelof