Can somebody help me please?
What is the problem with this very simple source code of Euclid algorthm?
#include <stdio.h>
void main(void)
{
unsigned long a,b,r;
unsigned long auxa, auxb;
printf("Introduceti valoarea lui a: "); scanf("%ld", &a);
printf("Introduceti valoarea lui b: "); scanf("%ld", &b);
auxa=a;
auxb=b;
while(b!=a)
{
r=a%b;
a=b;
b=r;
}
printf("-----------------------------\n");
printf("cmmdc(%ld, %ld)= %ld", auxa,auxb,a);
}
When I try to compile this code in Borland C++ 5.0 or even in Microsoft Visual Studio 2008 I receive this error message:
"Unhandled exception at 0x00f5144b in test.exe: 0xC0000094: Integer division by zero." (in Visual Studio 2008) and it seems that the error is in that line I marked with bold!