it's my first question on here, so I have to make program to run the euclidean algorithm, and this is the result:
printf("Bitte geben Sie eine Zahl ein: ");
scanf("%d\n", &a);
printf("Bitte geben Sie eine zweite Zahl ein: ");
scanf("%d\n", &b);
do
{
r = a % b;
a = (a / b) + r;
a = b;
b = r;
g = a;
} while (b != 0);
printf("Der groesste gemeinsame Teiler ist: %d\n", g);
The problem is that when I run the code, it goes like this:
printf("message")->scanf("&a")->scanf("&b")->printf("message")->scanf(doesn't matter)->printf("result")
But it's supposed to go like:
printf("message")->scanf("&a")->printf("message")->scanf("&b")->printf("result")
The algorithm works, but it's the input that is completely jacked, am I doing something wrong or could it be the compiler? I use msys2 gcc mingw64. Appreciate your help already!